Labels

slider

Recent

Navigation

Tab Control C# Windows Application

Tab Control, Tabs in Windows application, C# Tabs control, c# tab control, Tab Control C# Windows Application

Introduction

I am demonstrating in this example, how can we use tab control in C# windows application. My recent posts were on Export Gridview to Excel & Transpose Datatable C# now explaining about tab control in c# windows application.

Namespace  

    System.Windows.Forms

Step 1: Expand Containers tab of Toolbox, then drag Tab Control into your design window.


tab control




Step 2: In next step, click on tab control, and then click on TabPages property of tab control property. TabPages will navigate to popup windows where you can set tab pages names etc.

Tab Pages


Step 3: Now a popup window open with name TabPage Collection Editor, here in Text property, you can set tab page name, In Name property, you can set ID of the tab page. Consequences, you can set multiple tab pages as per your requirements on click Add button bottom of the window. You can also remove tab on click Remove property vice-verse.

TabPage Collection Editor


Step 4: Now you can see Tab pages view, here two tab pages are created Tab A and Tab B.

Tab View


Step 5: On particular click on radio button, you can view tab on your specific choice.

Tab B View

 

Shared code snippet below to select tab using C# (Windows Forms)

private void radioButton1_Click(object sender, EventArgs e)
{
    try
    {
 tabControl1.SelectTab("Testtab1");
 tabControl1.SelectedIndex = 0;
 tabControl1.TabPages[0].Show();
 tabControl1.TabPages[1].Hide();
    }
    catch (Exception ex)
    {
 throw ex;
    }
}
private void radioButton2_Click(object sender, EventArgs e)
{
    tabControl1.SelectTab("Testtab2");
    tabControl1.TabPages[1].Hide();
    tabControl1.SelectedIndex = 1;
}

Summary

This example demonstrates how to develop tab control C# Windows application development. In this example, showed fully how to design tab control, set its property and display it run time with code snippets. Moreover, fully functional project is available to download at the end of the article. 

Download Example in Zip 

Download Example Tab Control in Zip

Share

Anjan kant

Outstanding journey in Microsoft Technologies (ASP.Net, C#, SQL Programming, WPF, Silverlight, WCF etc.), client side technologies AngularJS, KnockoutJS, Javascript, Ajax Calls, Json and Hybrid apps etc. I love to devote free time in writing, blogging, social networking and adventurous life

Post A Comment:

2 comments:

  1. This appears to be for Windows Forms and not Windows Applications

    ReplyDelete
    Replies
    1. sure, it means to windows desktop applications.

      Delete