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.
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.
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.
Step 4: Now you can see Tab pages view, here two tab pages are created Tab A and Tab B.
Step 5: On particular click on radio button, you can view tab on your specific choice.
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; }
This appears to be for Windows Forms and not Windows Applications
ReplyDeletesure, it means to windows desktop applications.
Delete