Results 1 to 4 of 4

Thread: [RESOLVED] copying items from one box to another

  1. #1

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401

    [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

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    VB Code:
    1. Dim cbo1 As New ComboBox
    2.         Dim cbo2 As New ComboBox
    3.  
    4.         cbo1.Items.AddRange(New String() {"Item1", "Item2"})
    5.  
    6.         'make sure there are items
    7.         If cbo1.Items.Count > 0 Then
    8.             'make empty array to copy items into
    9.             Dim items(cbo1.Items.Count - 1) As Object
    10.             'copy items to array
    11.             cbo1.Items.CopyTo(items, 0)
    12.             'add to other combo
    13.             cbo2.Items.AddRange(items)
    14.         End If
    15.  
    16.         MsgBox(cbo2.Items.Count)

  3. #3
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    alternativly maybe , you could also try this...
    VB Code:
    1. [color=blue]Dim[/color] s [color=blue]As String[/color]
    2.         [color=blue]For Each[/color] s [color=blue]In[/color] ComboBox1.Items
    3.             [color=black]ComboBox2.Items.Add[/color](s)
    4.         [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]

  4. #4

    Thread Starter
    Hyperactive Member stingrae's Avatar
    Join Date
    Apr 2002
    Location
    Sydney
    Posts
    401
    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
  •  



Click Here to Expand Forum to Full Width