Jump to content

clone or copy comboBox

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
shinygold

shinygold

    Newbie

  • Members
  • Pip
  • 7 posts
Hello,

Can someone please tell me how I would create a clone or a copy of an existing ComboBox object?

I thought perhaps:
ComboBox newBox;

newBox = (ICloneable)((Object)existingBox).Clone();
but I was mistaken.

Thank you :)

Edited by Jaan, 09 June 2009 - 04:46 AM.
Please use code tags when you're posting your codes!


#2
Termana

Termana

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 4,057 posts
Why not just do this?:
            for (int i = 0; i < existingBox.Items.Count; i++)
            {
                newBox.Items.Add(existingBox.Items[i]);
            }

Interested in participating in community events?
Want to harness your programming skill and turn it into absolute prowess?
Come join our programming events!


#3
shinygold

shinygold

    Newbie

  • Members
  • Pip
  • 7 posts
Hi Termana,

Thanks for your response. I didn't do that because the I wanted the comboBoxes to have the same font, databindings, event handlers, and code attached to the previous ones. Obviously I could've just created my own cloneComboBox method, but I restructured my UI a little bit so I don't need it any more. Thanks though.