I have a combo box which is readonly. It is loaded with data from the database. However, there is a point that I need to set text on it, and those text is equal to one which is in its list aleady. The below code produces runtime error as my combo box is readonly. Is there any workaround to solve this issue?
You can do it by retriving the listindex value of that particular text, which you tried to select by default.
Make a function to get the SelectedIndex.
It should be like
Privat Function CheckIndex(ByVal key As String) As Integer
Dim Result As Integer = -1
For i As Integer = 0 To ComboBox1.Items.Count - 1
If ComboBox1.Items(i) = key Then
Result = i