Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

VB.NET ComboBox

 

I am trying to get the Text of a Combobox item by refferencing the index of the item.

 

Sounds pretty easy but ive been fooling with it for half an hour now and no luck.

 

Thanks in advance.

Posted

Doh, thats the first thing I tried :)

Brings around more problems then....

 

I have a sql string using ComboBox1.Items(0) during the form load which is giving me an out of bounds error, but its after the code which populates the list.

 

If I call MsgBox (ComboBox1.Items(0)) after the form is loaded it works fine giving me the first Item in the list.

 

How is this possible ?

Posted

To be more accurate, the error is:

An unhandled exception of type 'System.ArgumentOutOfRangeException' occurred in system.windows.forms.dll

 

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

 

with the line:

sSql = "SELECT * FROM Courses WHERE Name = '" & cboCourses.Items(0) & "'"

Posted
Ok, I guess the form designer code managed to trigger something cause I put a boolean var holding the db operation till the end of the form load and it works fine now.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...