Combobox Item Collection - working with a selection change

Jefferson

Member
Joined
Aug 16, 2005
Messages
21
Programming Experience
Beginner
Hi,

I am trying to disable textbox's on the change of the items in a combobox,
I have tried using the
combobox_selectionchangecommited()
combobox_selectedvaluechanged()
combobox_selectedIndexChanged()
and finally with the code attached
Private Sub cboBoxEmploymentStatus_Click
If cboBoxEmploymentStatus.Items Is "Permanent" Then
txtHourlyTCC.Enabled = False
ElseIf cboBoxEmploymentStatus.Items Is "Temporary" Then
txtMonthlyTCC.Enabled = False
ElseIf cboBoxEmploymentStatus.Items Is "Contractor" Then
txtMonthlyTCC.Enabled = False
txtHourlyTCC.Enabled = False
ElseIf cboBoxEmploymentStatus.Items Is "Learner" Then
txtMonthlyTCC.Enabled = False
End If
End Sub

But none of these seem to be working...
What event do i need to use???

Thanks for the help, awesome site???
Jefferson
 
VB.NET:
[SIZE=2][COLOR=#0000ff]Private [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ComboBox1_SelectedIndexChanged([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Object, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.EventArgs) [/SIZE][SIZE=2][COLOR=#0000ff]Handles[/COLOR][/SIZE][SIZE=2] ComboBox1.SelectedIndexChanged
[/SIZE][SIZE=2][COLOR=#0000ff] If[/COLOR][/SIZE][SIZE=2] ComboBox1.SelectedItem = "SomeSelection" [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]     TextBox1.Enabled = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff] End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

This works great for me. Make sure you are using SelectedItem or Text to retrieve the text in the ComboBox
 
combobox selecteditem - Resolved

Hi,

Thanks for that, Seems that i was entering the text incorrectly - did not realize that it was case sensitive.

Enjoy your day.
Jefferson
 
Back
Top