In load page event:
I read some data from DB and then add this data to Combo box then select an item as default and enable of combo box changes to false.
When I load this page, the item witch selected highlights with blue color.
How to remove this highlight?
You can modify its
SelectionLength property, which gets or sets how many characters have been selected (highlighted).
Just set it to
0 after you have selected the default item and you should be good to go:
ComboBox1.SelectionLength = 0
In your case this code is executed before the
Load event has finished. Due to this the form has not been rendered yet, which is why it is not working for you.
The simple fix is to add this in the form's
Shown event too:
Private Sub Form1_Shown(sender As Object, e As System.EventArgs) Handles Me.Shown ComboBox1.SelectionLength = 0 End Sub
If you don't want the caret to be in the beginning you can also add this line to set it to the end of the text:
ComboBox1.SelectionStart = ComboBox1.Text.Length