What I want to do is fairly simple. (or so I thought.)
I have 2 ComboBoxes on my Form each populated with the same data. I want to check when the user Selects an item in the second ComboBox and see if it is the same as the item they selected in the first ComboBox. If they are different then they can proceed, however if they are the same then they must choose a different item in the second ComboBox.
Here is a generic version of the code I am using in the SelectedIndexChanged Event of the second ComboBox.
If ComboBox2.Text = "Select a Colour" Then
Exit Sub
End If
If ComboBox2.Text = ComboBox1.Text Then
If MessageBox.Show("You must select a different Colour", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error) = DialogResult.OK Then
ComboBox2.Text = "Select a Colour"
Exit Sub
End If
' code here if the two selected items do not match
Now the hitch. The Text in the second ComboBox does not change to what I want, it actually reverts back to the Text of the Item selected.
Can anyone tell me how to go about setting the Text of a ComboBox?
I have 2 ComboBoxes on my Form each populated with the same data. I want to check when the user Selects an item in the second ComboBox and see if it is the same as the item they selected in the first ComboBox. If they are different then they can proceed, however if they are the same then they must choose a different item in the second ComboBox.
Here is a generic version of the code I am using in the SelectedIndexChanged Event of the second ComboBox.
If ComboBox2.Text = "Select a Colour" Then
Exit Sub
End If
If ComboBox2.Text = ComboBox1.Text Then
If MessageBox.Show("You must select a different Colour", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error) = DialogResult.OK Then
ComboBox2.Text = "Select a Colour"
Exit Sub
End If
' code here if the two selected items do not match
Now the hitch. The Text in the second ComboBox does not change to what I want, it actually reverts back to the Text of the Item selected.
Can anyone tell me how to go about setting the Text of a ComboBox?