Algar Posted August 4, 2003 Posted August 4, 2003 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. Quote
*Experts* mutant Posted August 4, 2003 *Experts* Posted August 4, 2003 ComboBox1.Items(indexnumber) This will return the text of the of item with the specified index. :) Quote
Algar Posted August 4, 2003 Author Posted August 4, 2003 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 ? Quote
Algar Posted August 4, 2003 Author Posted August 4, 2003 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) & "'" Quote
Algar Posted August 4, 2003 Author Posted August 4, 2003 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.