adding userControl to tabControl
how can i insert a userControl that contains buttons,lables to TabControl page in c#? (what is the code)
Notes:
- the 开发者_如何学运维tabControl is inside a userControl because i need this tabControl for other forms.
- i am using visual Studio 2008.
Code:
public Courses()
{
InitializeComponent();
ucAction1.tpDelete // (userControl name,firts tabControl tabPage), i dont know how to move on from here?
}
If you are just trying to add the usercontrol manually to the tabpage:
tabPage1.Controls.Add(ucAction1);
Update:
I "think" I understand your issue. In your tabcontrol inside your usercontrol, change the Modifiers property of each TabPage to Public. Then you can access it:
ucAction1.tabPage1.Controls.Add(new TextBox());
Public Sub addTabPage(ByVal Title As String)
Dim TPage As New TabPage(Title)
Dim UCInstance As New UControl()
TPage.Controls.Add(UCInstance)
TabControl1.TabPages.Add(TPage)
UCInstance.Dock = DockStyle.Fill
End Sub
call UserControl1
on tapPage1
like this
UserControl1 myUserControl = new UserControl1();
myUserControl.Dock = DockStyle.Fill;
tabPage1.Controls.Add(myUserControl);
精彩评论