A
Adam Biser
My apologies if this has been discussed before, but using Google and
also searching the newsgroup has not given me any insight to this problem.
I'm experiencing some strange behavior when I copy and paste a
usercontrol. What happens is that the controls inside the usercontrol
are being created on the form in addition to the copy of the usercontrol.
I'm using VS 2008 Pro, v9.0.21022.8 with .NET 3.5.
Here's how I can duplicate the problem:
1) Create a new Windows Application project.
2) Add a User Control class to the project
3) Add a Component class to the project
4) Change the Component class to inherit from System.Windows.Forms.TextBox.
The IDE will complain that the class already inherits from Component.
Change it so it inherits from TextBox instead.
5) Build
6) Add the Component to the User Control
7) Build
8) Add a User Control instance to the Form
9) Copy the User Control you just added.
10) Paste another instance to the form.
Now you should see the expected user control duplicate. However, check
out the control drop down list in the properties browser window. When
you drop down the list you should see (using the default names)
- Component11
- Form1
- UserControl11
- UserControl12
Why is Component11 there? All I did was copy UserControl11 and paste it
as UserControl12. Why does the User Control's internal component get
copied and becomes an external copy on the form. I find that I actually
have to delete these extra components.
Now if you copy/paste the second UserControl (the one you made with the
first paste), you'll get TWO extra controls (assuming you didn't delete
the first extra one).
- Component12
- object_6e47ae7a_3951_45fe_8305_9870c2cff6fe (or some similar name)
Am I neglecting to do something? Any information pointing me in the
right direction would be helpful.
Thanks
also searching the newsgroup has not given me any insight to this problem.
I'm experiencing some strange behavior when I copy and paste a
usercontrol. What happens is that the controls inside the usercontrol
are being created on the form in addition to the copy of the usercontrol.
I'm using VS 2008 Pro, v9.0.21022.8 with .NET 3.5.
Here's how I can duplicate the problem:
1) Create a new Windows Application project.
2) Add a User Control class to the project
3) Add a Component class to the project
4) Change the Component class to inherit from System.Windows.Forms.TextBox.
The IDE will complain that the class already inherits from Component.
Change it so it inherits from TextBox instead.
5) Build
6) Add the Component to the User Control
7) Build
8) Add a User Control instance to the Form
9) Copy the User Control you just added.
10) Paste another instance to the form.
Now you should see the expected user control duplicate. However, check
out the control drop down list in the properties browser window. When
you drop down the list you should see (using the default names)
- Component11
- Form1
- UserControl11
- UserControl12
Why is Component11 there? All I did was copy UserControl11 and paste it
as UserControl12. Why does the User Control's internal component get
copied and becomes an external copy on the form. I find that I actually
have to delete these extra components.
Now if you copy/paste the second UserControl (the one you made with the
first paste), you'll get TWO extra controls (assuming you didn't delete
the first extra one).
- Component12
- object_6e47ae7a_3951_45fe_8305_9870c2cff6fe (or some similar name)
Am I neglecting to do something? Any information pointing me in the
right direction would be helpful.
Thanks