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

Recommended Answers

All 4 Replies

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
:)

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

Hi,

Try this condition :

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

Regards
Veena

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.