Deathonly Deathonly - 1 year ago 121 Question

Textbox Enabled True False

This is code am trying to solve

Dim i As Integer
i = ListBox1.SelectedIndex
If ListBox1.SelectedIndex = 0 Then
TextBox10.Enabled = False
TextBox25.Enabled = False
TextBox30.Enabled = False
TextBox40.Enabled = False
TextBox55.Enabled = False
TextBox65.Enabled = False
TextBox73.Enabled = False
TextBox84.Enabled = False
TextBox95.Enabled = False
TextBox100.Enabled = False
TextBox185.Enabled = False
TextBox(??).Enabled = True

End If

How to other textboxes to enable True?
I mean
10,25,30,40... 185 are false and all other textboes Enabled true ?

Answer Source

You can find control of type textbox and assign default enabled= true and then write your code to set enabled=false.

For Each c As Control In Me.Controls
If c.GetType Is GetType(TextBox) Then
End If


Dim allTextBox As New List(Of Control)
For Each c As TextBox In FindControl(allTextBox, Me,GetType(TextBox))

Public Shared Function FindControl(ByVal list As List(Of Control), ByVal parent As Control, ByVal ctrlType As System.Type) As List(Of Control)
    If parent Is Nothing Then Return list
    If parent.GetType Is ctrlType Then
    End If
    For Each child As Control In parent.Controls
        FindControl(list, child, ctrlType)
    Return list
End Function
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download