Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

My website
Posted

Aha got the query result ok, SelectedItem not SelectedValue.

 

Just need to suss the displaying the first item...

My website
Posted

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? :-))

My website
  • *Experts*
Posted

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

"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

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...