How to: Add and Remove Tabs with the Windows Forms TabControl
By default, a TabControl control contains two TabPage controls. You can access these tabs through the TabPages property.
To add a tab programmatically
Use the Add method of the TabPages property.
Dim myTabPage As New TabPage() myTabPage.Text = "TabPage" & (TabControl1.TabPages.Count + 1) TabControl1.TabPages.Add(myTabPage)
string title = "TabPage " + (tabControl1.TabCount + 1).ToString(); TabPage myTabPage = new TabPage(title); tabControl1.TabPages.Add(myTabPage);
String^ title = String::Concat("TabPage ", (tabControl1->TabCount + 1).ToString()); TabPage^ myTabPage = gcnew TabPage(title); tabControl1->TabPages->Add(myTabPage);
To remove a tab programmatically
To remove selected tabs, use the Remove method of the TabPages property.
-or-
To remove all tabs, use the Clear method of the TabPages property.
' Removes the selected tab: TabControl1.TabPages.Remove(TabControl1.SelectedTab) ' Removes all the tabs: TabControl1.TabPages.Clear()
// Removes the selected tab: tabControl1.TabPages.Remove(tabControl1.SelectedTab); // Removes all the tabs: tabControl1.TabPages.Clear();
// Removes the selected tab: tabControl1->TabPages->Remove(tabControl1->SelectedTab); // Removes all the tabs: tabControl1->TabPages->Clear();
See also
Sadarbojieties ar mums vietnē GitHub
Šī satura avotu var atrast vietnē GitHub, kur varat arī izveidot un pārskatīt problēmas un atgādāšanas pieprasījumus. Lai iegūtu papildinformāciju, skatiet mūsu līdzstrādnieku rokasgrāmatu.
.NET Desktop feedback
Atsauksmes
https://aka.ms/ContentUserFeedback.
Drīzumā: 2024. gada laikā mēs pakāpeniski pārtrauksim izmantot “GitHub problēmas” kā atsauksmju par saturu mehānismu un aizstāsim to ar jaunu atsauksmju sistēmu. Papildinformāciju skatiet:Iesniegt un skatīt atsauksmes par