I have a few links which are disabled by default on a form, each using a LinkLabel
control.
Depending on some user interaction I need to enable either one or all of the LinkLables
. I can enable the single LinkLabel
just fine, but I can't find a way of enabling all of them.
In the example below I'm trying to enable all controls (as a test of my methodology), but that fails and the LinkLabels
are not enabled at all.
Therefore my question is two part -
- How can I identify only
LinkLabel
controls? - How can I loop throught these controls and enable them?
Here is what I have so far -
Private Sub EnableLink(Optional ByRef linkLabel As LinkLabel = Nothing)
If linkLabel Is Nothing Then ' Enable all links
For Each singleLink In Me.Controls
singleLink.Enabled = True
Next
Else ' Enable a single link
linkLabel.Enabled = True
End If
End Sub
Bonus question - I may need to separate my LinkLabels
in to two sections, so is there a way of identifying LinkLabels
which are placed within a specific control, such as a Panel
or TableLayoutPanel
?