Question : VB.net Tab Control - How to reuse control names on tabs

I have a tab control with a couple of tabs.
Many of the textboxes and buttons on the various tabs serve the same purpose and will trigger the same events and processing routines. (e.g. on tab 1 user can pastes text, on tab 2 user can import a file, in both cases text gets dumped into a textbox on the respective tab and the text is then processed the same way.)

I would like to give the controls the same name, e.g. on Tab1, txtTextbox, btnButton and on Tab2 txtTextbox and btnButton and then distinguish between which tab they are on by referencing the tabname.controlname or something similar but i"m not having any luck.

What is the correct way to distinguish between the tabs or correct parent name to use in this situation, or can it not be done at all?

Thanks in advance.

Answer : VB.net Tab Control - How to reuse control names on tabs

You can't automatically get a "fully qualified" control name that I'm aware of...you'd have to manually build up the name by ascending up the parent tree until you get to the form.

Visual Studio will not allow you to have controls with the same name on the same form...BUT it is actually possible at RUN-TIME to give controls the same name.

If you built a UserControl, though, then you could have the same name controls in each instance of the UserControl and simply place instances of the UserControl into your TabPages.
Random Solutions  
 
programming4us programming4us