all groups > vb.net controls > january 2005 >
You're in the

vb.net controls

group:

out of the range


out of the range Patricia Kline
1/31/2005 10:25:35 AM
vb.net controls:
I have a listbox.. i have a dataset that gets the values from the database
and i add three values to the dataset using code. If i have three or less
items in the database, it works fine. Once i add the fourth item.. I get
the following error when i try to set the SelectedValue of the listbox:

**************************************************************************
An unhandled exception of type System.ArgumentOutOfRangeException occurred
in system.winodws.forms.dll

Additional information: Specified argument was out of the range of valid
values.
***************************************************************************

The code is trying to set the value to one of the values that I added thru
the code, so I know it is in there. Anyone have any ideas.

Re: out of the range Chris, Master of All Things Insignificant
1/31/2005 12:33:37 PM
You don't show any code so it's hard to tell you what you are doing wrong.
The error is telling you that the index you are trying to set the listbox to
doesn't exist. Check the count of the items in the listbox before you set
the value.

Listbox.Items.Count

Chris

[quoted text, click to view]

AddThis Social Bookmark Button