0

hi,

I am trying to learn winforms, the dropdown is taking its value from database. i want to disable the textbox when the selection is first option, but if it is second i want to enable the textbox..

how would i do this ?

thanks

4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by Jx_Man
0

On the SelectedIndexChanged event of the combobox add your code as (Where 'A', 'B' and 'C' are the items in your dropdown)

If ComboBox1.Text = "A" Then
ComboBox1.Enabled = False
ElseIf ComboBox1.Text = "B" Then
ComboBox1.Enabled = True
ElseIf ComboBox1.Text = "C" Then
ComboBox1.Enabled = True
End If

Regards
:)

0

thanks for the reply, but i was wondering is there another way like maybe using the index(0) of the value to disable the textbox

0

Hi,

Try this condition :

If Combo1.SelectedIndex = 0 Then
    ' Code to disable
Else
    ' Code to Enable
End If

Regards
Veena

0

veena answered it. but you also can do with selected item :

If Combo1.SelectedItem = "What" Then
    Textbox1.Enable = False
Else
    Textbox1.Enable = True
End If
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.