According to another forum, this is not a MS issue, because they say that is the “native” behavior of the CombBox.
If the ComboBox has a DropDownStyle = DropDown and changes its size, the text is highlighted, if the form has many ComboBox seems that the controls are selected.
To avoid this issue one guy suggest to override the WndProc.
Everything was working fine until just one client has reported an unhandled error
System.ArgumentOutOfRangeException: InvalidArgument=Value of '-2136611475' is not valid for 'start'.
Parameter name: start
at System.Windows.Forms.ComboBox.Select(Int32 start, Int32 length)
at System.Windows.Forms.ComboBox.set_SelectionLength(Int32 value)...............
class ComboBoxEx : ComboBox
{
const int WM_SIZE = 5;
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case WM_SIZE:
string text = Text;
base.WndProc(ref m);
//The exception strangely is trown here
SelectionLength = 0;
Text = text;
break;
default:
base.WndProc(ref m);
break;
}
}
}
I don’t know the reason why this is happening just with one client.
I can’t think of a case that will cause that, but I have a workaround. I checked set_SelectionLength(Int32 value) in the reflector:
I don’t no why SelectionStart suddenly become a negative number but you can cut the middleman and preform this workaround code: