I would like to duplicate a control on my form, with a user control, which has the same name with a 'new' added to it. (Label1 ----> newLabel1)
this is my code snippet:
Private Sub CreateLabel(ByRef lblControl As Control)
'lblControl - this is the control i would like to duplicate
'The reference to the new created control itself so i can work with it within this sub.
Dim newControl As Control
Set newControl = Form1.Controls.Add _
("Project.Project1", "new" & lblControl.Name, lblControl.Container)
newControl.Visible = True
End Sub
It works great if i want to duplicate a control which isn't indexed how ever, i am having trouble duplicating a control which is in an array as lblControl.Name simply take its name, not its index, and replacing the name with an indexed name (lblControl.Name & "(" lblControl.Index & ")" doesn't work really ..
In addition, creating a control and changing its index value after creation is not working.
So my question is, how can i create an array using the above method ?