Results 1 to 5 of 5

Thread: Copying an existing control...

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297

    Copying an existing control...

    Hey everyone,

    I know this is a common question, and I apologize, but I searched the forum and couldn't find an appropriate response.

    I've already got one listview on my form, and depending on the situation, when this form opens it may have any number of additional listviews. I'd like to dynamically load them and have all the same properties as the listview that is already on the form.

    I tried:
    Code:
    Dim lvTemp as New lvGE
    'lvGE is the Listview control that is already on, and always on my form
    With no success. What am I missing?

    Thanks!

    --Ben

  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Dublin (Ireland)
    Posts
    304
    You have to add it to the controls collection of the form

    don't have code to hand, but the form is the parent control and search for words like parent control add and something should come up to give you the answer

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2001
    Location
    Buffalo, NY
    Posts
    297
    Sorry for not being more specific.

    I am adding it to the controls collection, but it's the DIM line that's erroring out. Won't compile it.

    --Ben

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    VB Code:
    1. Dim lvTemp as ListView = DirectCast(lvGE , ListView)
    ~
    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]

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Originally posted by dynamic_sysop
    VB Code:
    1. Dim lvTemp as ListView = DirectCast(lvGE , ListView)
    Actually this will make a second reference to the same listview not copy/duplicate one. There is no simple method to copy a control. You can either recreate it (run the code that the IDE generates that creates it), or in some cases you can serialize it to copy it. However I don't think the ListView control is serializable.

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