|
-
Sep 22nd, 2003, 02:28 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] copying items from one box to another
what's the best method for copying all the items from one combo box, into a different combo box?
Last edited by stingrae; Sep 23rd, 2003 at 12:34 AM.
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
-
Sep 22nd, 2003, 03:22 AM
#2
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)
-
Sep 22nd, 2003, 06:35 AM
#3
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]
~
if a post is resolved, please mark it as [Resolved]
protected string get_Signature(){return Censored;}
[vbcode][php] please use code tags when posting any code [/php][/vbcode]
-
Sep 23rd, 2003, 12:33 AM
#4
Thread Starter
Hyperactive Member
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 ....
"The passion lives to keep your faith, though all are different, all are great" ... Michael Hutchence 1960-1997.
Windows & Web Developer
Specialising in Visual Basic .Net & Client Server Programming & Client/Customer Relations Databases
Sutherland Shire, Sydney Australia
www.stingrae.com.au
Developer of Arnold - Gym & Martial Arts Database Management System
www.gymdatabase.com.au
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
|