Reusing textbox on multiple tabs in a tab control.

  • Thread starter Thread starter William Stacey [MVP]
  • Start date 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!
 
* "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.
 
\\\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);
}
///
 
Back
Top