Control name from tabindex

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • danielmaz
    New Member
    • Sep 2008
    • 1

    Control name from tabindex

    Hello people,
    How I can retrive the control name (ex: textBox12) from a known tabindex (ex: 12).
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    I'm not sure I know which control you are trying to get the name of.
    Is it that you want the name of a text box on the tab control, or that you want the name of the tab control itself?

    A tabcontrol has a collection of TabPages.
    A TabPage as a collection of Controls.

    So you can loop through all the TabPages and within that loop through all its Controls to get their names. But you need a way to know you have gotten the right control. If your TabPage only has one TextBox for example then it becomes significantly easier because you loop through all the controls until you find the one whose type is TextBox. But if you have a lot of TextBoxes it becomes a problem. You could do a lot of fancy switch and if logic... Maybe identify it based on its TabIndex which should be the same from TabPage to TabPage...

    Or, since you had to build the controls and put them on the TabPages to begin with, it might be best to assign the names as you build the TabPages. Now you know the name before its ever displayed and it will retain that name for its lifespan or until you change it programmaticly.

    Comment

    Working...