Wednesday, May 17, 2006

Fun with Windows Forms #1

The exception:
System.ArgumentOutOfRangeException: InvalidArgument=Value of '-1379311' is not valid for 'length'.
Parameter name: length
at System.Windows.Forms.ComboBox.Select(Int32 start, Int32 length)
at System.Windows.Forms.ComboBox.set_SelectionStart(Int32 value)

The code:
ComboBox cb;
cb.SelectionStart = cb.Text.Length;

The fix:
cb.Select(cb.Text.Length, 0)

1 comment:

Anonymous said...

I have this error too.. But I can't understand what is causing it!!!

(BTW: the number changes often)