I'm using this subroutine to recursively toggle disabled/invisible state for a control and its children:
This works for everything except tabcontrols. On a tabcontrol, it hides/disables the correct fields on the front tabpage, but not any of the other pages. If I click on a different tabpage and then run the subroutine, it will hide/disable the controls on that page correctly, but that page only. How can I make it run through all the controls on all the tab pages every time?
Code:
Public Sub ConcealObject(ByVal Parent As Control)
For Each C As Control In Parent.Controls
'conceals the control
If C.Enabled = False OrElse C.Visible = False Then
If CStr(C.Tag) <> "noconceal" Then 'a tag that are either never disabled or never hidden and thus shouldn't be toggled
Conceal(C)
End If
ElseIf C.HasChildren Then
ConcealObject(C) 'repeats the loop at the next level down (will keep repeating for as many levels as there are)
'NOTE: This can't turn into an endless loop because it's always going down a level and control inheritance can't be cyclical
End If
Next C
End Sub