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!

Add User Control programmatically 1

Status
Not open for further replies.

MDA

Technical User
Jan 16, 2001
243
US
Hi all,

I have several user controls I have created, (first time using User Controls). It seems that if you drag & drop the control on a form, the control is not updated if a change is made to the user control. Is it possible to add the control to the main form programmatically? I want to make sure that if I make a change to the user control, the change will show on my main form.

Any feedback is greatly appreciated.
Regards,
MDA

FYI Code that shows in VB generated code:
Friend WithEvents InteriorForm1 As MetaWizard.InteriorForm
Me.InteriorForm1.BackColor = System.Drawing.SystemColors.Control
Me.InteriorForm1.Location = New System.Drawing.Point(0, 0)
Me.InteriorForm1.Name = "InteriorForm1"
Me.InteriorForm1.Size = New System.Drawing.Size(497, 313)
Me.InteriorForm1.TabIndex = 15
Me.InteriorForm1.Visible = False
 
when you say "modify" the user control, do you mean that you're changing the code for the user control, or that you're changing some property of the instance of the user control in your main project. if you're changing the user control code itself, you need to rebuild the user control project to see the changes in your other project that uses it.
 
Thanks,

I mean when I change code in the user control.
The user controls and the "main" form are in the same project. Perhaps I am not using the User Control as it should be used. My goal is to create a "wizard" like project and I thought it would make it easy to create a new user control for each "page" in the wizard.

It seemed that even after I rebuilt the project, the user control stayed the same on the main form. So I had to delete the control from the form and drag & drop the user control back on the main form to see the changes. Make sense?

What do you think?
Mike
 
hmm, i have to admit i'm no expert on user controls, but i work w/ them also and i don't have that problem. you said that the user control is part of the same project as your main form. are they really part of the same project or are they different projects, but part of the same solution? if they're part of the same project, try breaking them out so that your user control is one project and the main form is another, but both are part of the same solution. i don't have any technical reason for knowing that will make a difference, but that's how i've got my end set up and it works fine.
 
if you are making changes to the code of the control then you will need to recompile the whole solution for the changes to be replicated where the control is on a form

if you are changing properties in code it should be of the control on your main form and not the usr control properities. if on your main form where the control is residing you cant see the property you need access, make sure that you have in the usrcontrol project set that propert so that it can be set. if necessary make your the controls that make your usrcontrol public. this will expose the properties for them automatically
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top