Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replicate control

Status
Not open for further replies.

shatch

Programmer
Jul 9, 2004
346
GB
Hi

I need to write a function which will take in a control and create a new instance of its type (an new instance of it), does anyone have any ideas?

Thanks in advance

S.
 
something like this? I havent tried it!

Code:
private function f1(byref con1 as object)
  dim newcontrol as object
  newcontrol = ctype(con1,con1.gettype)

end function

Christiaan Baes
Belgium

If you want to get an answer read this FAQ faq796-2540
What a wonderfull world - Louis armstrong
 
No, tried that, error is con1.gettype is not defined...

This is really doing my head in, it seems so simple
 
Well, for those of you that are interested and want to use it i found the answer:

Dim myType As Type = ControlToReset.GetType
Dim objControl As Object = myType.GetConstructor(myType.EmptyTypes).Invoke(Nothing)

Glad to have made it in the end :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top