C# version here.
This code will visit every control on a form, regardless of how deeply it's nested. You could have a TextBox in a Panel in a Splitter in a GroupBox in a TabPage in a TabControl in a Panel and it will still be found. No recursion is needed on your part, as this will simply follow the tab order from start to finish. It also doesn't matter if a control has it's TabStop set to False, as it must still have a TabIndex.No doubt the GetNextControl method uses recursion internally, but that's not our concern. This will keep your code nice and neat and you'd need a very, very large number of controls before you'd notice a difference in performance.VB Code:
Dim ctl As Control = Me.GetNextControl(Me, True) 'Get the first control in the tab order. Do Until ctl Is Nothing 'Use ctl here. ctl = Me.GetNextControl(ctl, True) 'Get the next control in the tab order. Loop




Reply With Quote