Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

set combo box to null/nothing 1

Status
Not open for further replies.

richey1

Technical User
Oct 5, 2004
184
GB
I've got a groupbox with 2 values and a combo box

on the leave of the groupbox, if the groupbox value is 1 I want to, if there is a value in there, to set the combo box to null/nothing

any ideas ?

thanks
kim
 
Setting the SelectedIndex property of the combobox to -1 should do the trick
 
just one problem with that for me. it does work, but it just sets it back to the first selection in my combo box - i.e. doesn't null it because I don't have a blank row in the table it reads from ?

thanks
 
Hello, why not set the text value to "", it works for me.
ucsjimj
 
hi

yeah i tried all them to start with, "" null etc but none of those work - the selected index will work if i have a blank row in the table values but I don't really want to do that.
 
richey

Im not sure how you populate the combo in the first place, and as such some of the code below may be redundant, but it will give you the exact effect you require.
Code:
With xCombo
      .DataSource = Nothing
      .DisplayMember = ""
      .ValueMember = ""
      .Items.Clear()
      .Items.Add("<Nothing>")
      .SelectedIndex = 0
      .Enabled = False
End With





Sweep
...if it works dont mess with it
 
brilliant !
works a treat
thanks.........
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top