hog Posted May 22, 2003 Posted May 22, 2003 If I add a list of items to a combobox any ideas on how I solve the following: I assign 5 values to a combobox using the items.add method, but when I try to query the users selection using selectedvalue it returns nothing. Is there some other way to add items, or is there a step I have missed. Also how do I make the first item added to the list appear in the combobox, cuurently it appears blank and the user has to click on the control to display the values. On other comboboxes on the form which I have pre assigned values I use selectedvalue and it works ok Quote My website
hog Posted May 22, 2003 Author Posted May 22, 2003 Aha got the query result ok, SelectedItem not SelectedValue. Just need to suss the displaying the first item... Quote My website
Administrators PlausiblyDamp Posted May 22, 2003 Administrators Posted May 22, 2003 Not sure if it's the best way but it worked in my epic 4 line test app ;) ComboBox1.Text = ComboBox1.Items(0).ToString Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
hog Posted May 22, 2003 Author Posted May 22, 2003 Aha.....that works a treat...ta Also I was always taught the following about programming.. There is no wrong way to program, as if it works it's right. There is only efficient and inefficient ways to program! PS like you name.......does it mean what it I think it means? :-)) Quote My website
Administrators PlausiblyDamp Posted May 22, 2003 Administrators Posted May 22, 2003 'fraid so - was the result of trying to think of a name for a Quake2 LAN session after a few too many beers, kind of stuck because I find it amusing. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
*Experts* Nerseus Posted May 22, 2003 *Experts* Posted May 22, 2003 I'd use "ComboBox1.SelectedIndex = 0" to select the first item. Setting the Text property may work, but it will cause an error if the style is set to dropdownlist (where you can't type in values in the ComboBox). -Nerseus Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
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.