-
June 11th, 2008, 08:29 PM
#1
Combobox.Items.Clear not working!
I load a Combobox with the following code:
Code:
Public colCustomers As List(Of Customers) = Nothing
Public Sub LoadCustomers(ByVal cbx As ComboBox)
If colCustomers Is Nothing Then
colCustomers = LoadCustomerList()
End If
cbx.Items.Clear()
For Each Customer In colCustomers
'Code to Add Customers
Next
End Sub
I need to be able to call this function again and have it clear the combobox and reload the Customer List into it. However, when I call the function a second time, it leaves the name of the last Customer that was selected. cbx.SelectedIndex = -1, but cbx.Text = "Customer Name". I need this combobox to be completely cleared out with nothing selected and nothing displayed. Why doesn't cbx.Items.Clear clear the cbx completely?
I'd rather be wakeboarding...
-
June 11th, 2008, 10:33 PM
#2
Re: Combobox.Items.Clear not working!
I haven't paid much attention to the combo box in dot net but in vb 6 it has a style property that prevents text which is not in the list, If memory serves it defaults to combo and needs to be changed to drop down list to achive what you are looking for. Of course dot net may be different but it is something to take a look at.
-
June 12th, 2008, 01:32 AM
#3
Re: Combobox.Items.Clear not working!
malleyo, you can set the DropDownStyle property of the ComboBox to DropDownList, that should work
-
June 16th, 2008, 12:23 PM
#4
Re: Combobox.Items.Clear not working!
It worked! Thanks!
I'd rather be wakeboarding...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|