Click to See Complete Forum and Search --> : control arrays 2
mkandil
Jun 23rd, 2002, 10:16 AM
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?
Musician
Jun 23rd, 2002, 11:03 AM
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.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.