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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a UserControl at runtime without Control Arrays

Status
Not open for further replies.

robdon

Programmer
May 21, 2001
252
ES
Hi,

Does anyone know how to create a UserControl at runtime, without using Control Arrays?

I can create standard control like this...

Dim ctlName As Control

Set ctlName = Form1.Controls.Add("VB.Textbox", "Text1", Form1)

ctlName.Visible = True


But I cant find out how to create a UserControl dynamically at runtime.

The UserControl is designed at design time, I just want to include it on a form at runtime...

Thanks,

Rob D

ProIV Resource Centre
 
Hi,

Just so others know, I figured it out.

Dim ctlName As Control

Set ctlName = Form1.Controls.Add("Project1.UserControl1", "Text1", Form1)

ctlName.Visible = True

You have to replace "VB.TextBox" with the projectname and the usercontrol name, not just the usercontrol name.

Also, in project properties under the 'Make' tab, you have to make sure that the 'Remove Information about unused ActiveX controls' checkbox is unchecked...

Rob.

ProIV Resource Centre
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top