Combo Boxes - Empty or Full ?

G

garfitz

How can I tell if a ComboBox has any items ?

I've tried the following but it does not work when the
combobox is empty as element 0 is NULL and therefore
throws a NULL reference error. Any ideas ?

If cmbVwCustomer.Items(0) = "" Then
' combo box is empty, populate
End If
 
J

Jon Skeet

garfitz said:
How can I tell if a ComboBox has any items ?

I've tried the following but it does not work when the
combobox is empty as element 0 is NULL and therefore
throws a NULL reference error. Any ideas ?

If cmbVwCustomer.Items(0) = "" Then
' combo box is empty, populate
End If

Use ComboBox.Items.Count perhaps?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top