what's the best method for copying all the items from one combo box, into a different combo box?
Printable View
what's the best method for copying all the items from one combo box, into a different combo box?
VB Code:
Dim cbo1 As New ComboBox Dim cbo2 As New ComboBox cbo1.Items.AddRange(New String() {"Item1", "Item2"}) 'make sure there are items If cbo1.Items.Count > 0 Then 'make empty array to copy items into Dim items(cbo1.Items.Count - 1) As Object 'copy items to array cbo1.Items.CopyTo(items, 0) 'add to other combo cbo2.Items.AddRange(items) End If MsgBox(cbo2.Items.Count)
alternativly maybe , you could also try this...
VB Code:
[color=blue]Dim[/color] s [color=blue]As String[/color] [color=blue]For Each[/color] s [color=blue]In[/color] ComboBox1.Items [color=black]ComboBox2.Items.Add[/color](s) [color=blue]Next[/color]
Edneeis,
thankyou very much. you are a champion!
Dynamic_sysop,
thanks for the idea. i tried that too, but since my combo has 16000 items (australian suburbs), it took just as long!! ;)
time for a beer now ....