Q:

How to deselect the text of a combobox

I have a krypton combo box which I data bind with a list of key-value pairs. What's happening is that when I set the selected item in code, it is highlighting the text. How can I prevent this or deselect the text?
I've tried the following:
// 1
combo.Select(0,0);
// 2
combo.Focus();
anotherControl.Focus();
// 3
combo.SelectionStart = 0;
combo.SelectionLength = combo.Text.Length;
// 4 
combo.SelectionStart = combo.Text.Length;
combo.SelectionLength = 0;

Nothing seems to work. Any help is appreciated.

A:

I managed accomplishing this be overriding the OnPaint event of my control/window and doing
combobox1.SelectionLength = 0;

A:

I may have found a solution that works:
If you are using a form, subscribe to the form's Shown event.
OR
If you are using a UserControl (like I am), you can subscribe to the VisibleChanged event.
In the event, you can then do the following:
        foreach (ComboBox cbo in (this.Controls.Cast<Control>().Where(c => c is ComboBox).Select(c => (ComboBox) c)))
        {
            cbo.SelectionLength = 0;
        }

As an aside:
I ended up having to do this for a user control in which I added ComboBoxes to the control and then needed to later dynamically set their size. Setting the size caused the highlighting that the OP was encountering.

