combobox and string array

  • Thread starter Thread starter plutoplanet
  • Start date Start date
P

plutoplanet

Hi all,

I've got an array of strings which I need to put into a combobox:

dim s() as string
s(0) = "test"
s(1) = "also"
s(2) = "three"
' right now i do it this way...
Dim i As Integer
For i = LBound(s) To UBound(s)
ComboBox.Items.Add(s(i))
Next i

---> Isn't there another way???
Herwig
 
You can bind the data to the ComboBox.

Dim MyStringArray() As String = {"One", "Two", "Three"}
Me.ComboBox1.DataSource = MyStringArray
 
Dim MyStringArray() As String = {"One", "Two", "Three"}
Me.ComboBox1.DataSource = MyStringArray

This works, somehow.
But unfortunatly it is several times slower than the loop method.
Isn't there a faster way?
 
Manual adding is always going to be faster than data binding for small data
sets. The loop is probably the best option.

-Chris
 
Back
Top