Reusing textbox on multiple tabs in a tab control.

  • Thread starter William Stacey [MVP]
  • Start date
W

William Stacey [MVP]

Have a form with a tab control an ~10 tabs. Each contains its own controls,
but 2 text boxes are common on each tab control. Is there a way to leverage
the *same text box on multiple tabs so I can use the same one and not have
tbNameTab1, tbNameTab2, tbNameTab3, etc. This would allow me to leverage
some logic across tabs. Cheers!
 
H

Herfried K. Wagner [MVP]

* "William Stacey said:
Have a form with a tab control an ~10 tabs. Each contains its own controls,
but 2 text boxes are common on each tab control. Is there a way to leverage
the *same text box on multiple tabs so I can use the same one and not have
tbNameTab1, tbNameTab2, tbNameTab3, etc. This would allow me to leverage
some logic across tabs.

Move them outside a tabpage, then move them to the desired position in
front of the tabcontrol. When dragging the textbox, make sure, not to
move the mouse outside the area of the control you are currently
dragging. Alternatively, move the tabcontrol away, place the textboxes
directly on the form and move the tabcontrol behind the textboxes.
 
M

Mick Doherty

\\\VB
Private Sub TabControl1_SelectedIndexChanged(...)...
Dim CommonTextBox() As Control ={TextBox1,TextBox2}
TabControl1.SelectedTab.Controls.AddRange(CommonTextBox)
End Sub
///
\\\C#
private void tabControl1_SelectedIndexChanged(...)
{
Control[] commonTextBox={textBox1,textBox2};
tabControl1.SelectedTab.Controls.AddRange(commonTextBox);
}
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top