|
-
Oct 24th, 2002, 06:09 PM
#1
Thread Starter
yay gay
TabControl...
how do i put controls at run-time in tabs created at run-time in a tabcontrol?
-
Oct 24th, 2002, 07:45 PM
#2
VB Code:
Dim txt As New TextBox()
TabControl1.Controls.Add(txt)
txt.Visible=True
txt.Location=New Point(0,0)
-
Oct 25th, 2002, 07:45 AM
#3
Thread Starter
yay gay
An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll
Additional information: Cannot add 'TextBox' to TabControl. Only TabPages can be directly added to TabControls.
-
Oct 25th, 2002, 10:24 AM
#4
Opps that is my bad, you have to add it to the TabPage1.Controls collection not the tabcontrol itself, sorry. If there are no tabpages then you can add one to the tab control then add the controls to it.
VB Code:
Dim tp As New TabPage()
TabControl1.Controls.Add(tp)
Dim txt As New TextBox()
tp.Controls.Add(txt)
txt.Visible=True
txt.Location=New Point(0,0)
-
Oct 25th, 2002, 02:54 PM
#5
Thread Starter
yay gay
-
Oct 25th, 2002, 02:58 PM
#6
Thread Starter
yay gay
i have a question..imagine i want to create tabs at run-time and create in them textbox's at run-time..how do i do that?
-
Oct 25th, 2002, 03:08 PM
#7
Originally posted by Edneeis
VB Code:
Dim tp As New TabPage()
TabControl1.Controls.Add(tp)
Dim txt As New TextBox()
tp.Controls.Add(txt)
txt.Visible=True
txt.Location=New Point(0,0)
That is exactly what that does. You'll probably want to change the location to something other than the very top left most corner though.
-
Oct 25th, 2002, 03:10 PM
#8
Thread Starter
yay gay
-
Oct 25th, 2002, 03:17 PM
#9
Thread Starter
yay gay
ah tks did what i want :
PHP Code:
private void button2_Click(object sender, System.EventArgs e)
{
TabPage tpTab = new TabPage(tabControl1.TabPages.Count.ToString());
tabControl1.TabPages.Add(tpTab);
TextBox ttBox = new TextBox(); ttBox.Text = (tabControl1.TabPages.Count - 1).ToString();
tpTab.Controls.Add(ttBox);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|