Results 1 to 2 of 2

Thread: control arrays 2

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2002
    Posts
    8

    control arrays 2

    i dont want to create the control array to hadle events.
    i need to create copies of an existing control with its properties at run time. how can i do that if there r no control arrays in vb.net?

  2. #2
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    All you have to do is create a new reference of the control. For example if you have a textbox called TextBox1 then:-

    Dim tbNew as New TextBox1
    tbNew.Text = "Copy of TextBox1"
    tbNew.Location = New System.Drawing.Point(12, 12)
    Me.Controls.Add(tbNew)

    Don't make the mistake of ignoring the value of AddHandler. Your question is based on a technique in VB6 where you had to place control on the form to allow the programmatic creation of a control array. You don't have to do this anymore so you shouldn't still be thinking in those terms.

    I have done an example of creating controls, using buttons, on the fly and using one procedure to capture the click event of all of them:-

    http://www.developerfusion.com/show/2499/

    Eventually you'll see that you just don't need control arrays anymore.

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