SelectedValue problem

praetor

Member
Joined
Feb 10, 2005
Messages
10
Programming Experience
5-10
I'm using a combobox with the property DropDownStyle set to DropDownList. The combo is data-bound to a dataset with two colums: ID, Name and it contains the following records:
ID Name
1 A
2 B
3 C
5 D

The DisplayMember property is mapped to "Name" column and the ValueMember property is mapped to "Id" column.
Everytime I try to set the SelectedValue of the combo to the value 1, the execution crashes showing the following error message:
Specified argument was out of range of valid values. Parameter name: '-2147483648' is not a valid value for 'index'.
The is no problem setting the SelectedValue to 2 or 5 or anything else. I have also a second combo with exactly the same parameters and data-binding on the form, and the is no problem with it.
Any ideas?
 
Last edited:
With tmp.Rows.InsertAt(row, 0) I'm trying to insert an empty item at the begining of the combo list, after the data binding's been created. The combination of putting the empty item at the position 0 and subsequently setting the SelectedValue to 1 seems to trouble vb.net and causes the error message to pop up. If I insert the empty row at position 1 or at the end, everything's ok.
 
Still no success. And this problem is starting to spread through the new forms added to my project...it really sux.
Anyway, thank you TPM, for your advice and patience and if anyone could figure out, what's going on there, it would be greatly appreciated.
 
Back
Top