I need to be able to make the disabled objects in my project invisible and vice-versa. Is there a way I can find a set of all the disabled objects in the project to set them all invisible?
Printable View
I need to be able to make the disabled objects in my project invisible and vice-versa. Is there a way I can find a set of all the disabled objects in the project to set them all invisible?
If you mean controls then you can do so using linq provided all your controls are in the same container:
If you have more than one container I would use a loop:VB.NET Code:
For Each Ctrl As Control In Me.Controls.OfType(Of Control).Where(Function(c) Not c.Enabled) Ctrl.Visible = False Next Ctrl
To Show the enabled controls you just do the opposite.VB.NET Code:
'Start the loop on your topmost container i.e. the form. HideDisabledControls(Me) Private Sub HideDisabledControls(ByVal Parent As Control) For Each C As Control In Parent.Controls If Not (C.Enabled) Then C.Visible = False ElseIf C.HasChildren Then HideDisabledControls(C) End If Next C End Sub
HTH