473,657 Members | 2,474 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Weird UserControl behavior

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
Oct 1 '08 #1
4 1320
On Oct 1, 1:09*pm, Adam Biser <adam-at-REMOVEgoodinass ociates-dot-com>
wrote:
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
If you believe this is a bug you should report it to the .NET
development teams using http://connect.microsoft.com/

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Oct 2 '08 #2
rowe_newsgroups wrote:
On Oct 1, 1:09 pm, Adam Biser <adam-at-REMOVEgoodinass ociates-dot-com>
wrote:
>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

If you believe this is a bug you should report it to the .NET
development teams using http://connect.microsoft.com/

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Thanks for pointing me at that site. After digging around there awhile
and not finding anything, I have posted it as a bug report.

Adam
Oct 2 '08 #3
On Oct 2, 12:58*pm, Adam Biser <adam-at-REMOVEgoodinass ociates-dot-
comwrote:
rowe_newsgroups wrote:
On Oct 1, 1:09 pm, Adam Biser <adam-at-REMOVEgoodinass ociates-dot-com>
wrote:
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
If you believe this is a bug you should report it to the .NET
development teams usinghttp://connect.microso ft.com/
Thanks,
Seth Rowe [MVP]
http://sethrowe.blogspot.com/

Thanks for pointing me at that site. *After digging around there awhile
and not finding anything, I have posted it as a bug report.

Adam
Sorry I couldn't have been more help - but from experience when it
comes to bugs there's not much more you can do except file a bug
report.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Oct 3 '08 #4
rowe_newsgroups wrote:
On Oct 2, 12:58 pm, Adam Biser <adam-at-REMOVEgoodinass ociates-dot-
comwrote:
>rowe_newsgroup s wrote:
>>On Oct 1, 1:09 pm, Adam Biser <adam-at-REMOVEgoodinass ociates-dot-com>
wrote:
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
usercontro l. 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
If you believe this is a bug you should report it to the .NET
development teams usinghttp://connect.microso ft.com/
Thanks,
Seth Rowe [MVP]
http://sethrowe.blogspot.com/
Thanks for pointing me at that site. After digging around there awhile
and not finding anything, I have posted it as a bug report.

Adam

Sorry I couldn't have been more help - but from experience when it
comes to bugs there's not much more you can do except file a bug
report.

Thanks,

Seth Rowe [MVP]
http://sethrowe.blogspot.com/
I wasn't sure if it was a bug or if I was doing something wrong. Since
searching yielded no results, I thought it must be what I'm doing or not
doing.

Thanks again for pointing me in the direction of that site,
Adam
Oct 3 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3849
by: Peter Wone | last post by:
Hosting the WebBrowser control is easy. Customising it is not. You have to implement IDocHostShowUI, IDocHostUIHandler, IDocHostUIHandler2, and IOleClientSite, not one of which appears in a typelib that I could find. With aid from around the world I did just that, and put together a comprehensive set of interfaces and enumerations, and I used them on my forms to set up the form as the client site for the browser object implementing...
2
4628
by: Sascha | last post by:
Hi there, I searched carefully through the web before finally deciding to post this message, because I could not find a solution for my problem. Hopefully someone will have a hint or explanation for me! I apologize for the length of this posting, but I wanted to make sure that I get an answer other than "Hey man, just use LoadControl!", because this is not what I want. The Task: Isolate a collection of web forms which are created as
4
1700
by: Michael Maes | last post by:
Hi, I have a UserControl with some "Children" (e.g. one ComboBox & one Label). I add the UserControl on a Form. If I perform a recursive scan through that Form's Control-Collection the ..HasChildren-Method scans the Controls within the UserControl. This is a behavior I want to ommit. * Is there a way to hide the Controls contained within a UserControl so that UserControl.HasChildren will always return False? *
10
4008
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the application. What should happen, is that the main MDI form should close, taking the child forms with it. There is code to loop through the child forms, remove the controls on each of them, and then close the form, but this code should execute only...
0
1044
by: Rob Blij | last post by:
Hi We have ported a .NET1.1 ASP.NET app to .NET2. All our user controls have been modified and I have found some strange behavior. Firstly I can see that the controls now get rendered at compile time instead of declaring them in the ascx.cs file. Then strange thing is: in our aspx page when we call Page.LoadControl(usercontrol) all the controls within the usercontrol dont get their unique ID ie ctl1_btnDetails etc except each...
0
1213
by: Rob Blij | last post by:
Hi (sorry for repeated question) We have ported a .NET1.1 ASP.NET app to .NET2. All our user controls have been modified and I have found some strange behavior. Firstly I can see that the controls now get rendered at compile time instead of declaring them in the ascx.cs file. Then strange thing is: in our aspx page when we call Page.LoadControl(usercontrol) all the controls within the usercontrol dont get their unique ID ie...
10
2417
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's my question. Once the UserControl is dropped onto the container page, how can I perform some action on the codebehind of the container page from the codebehind of the UserControl? For instance, suppose that the UserControl is dropped inside one...
1
2331
by: Tony Johansson | last post by:
Hello! I'm reading in a book and here they says. "Now it is time to begin thinking about which events the control should provide. Because the control is derived from userControl class, it has inherited a lot of functionality that you don't need to worry about. There are, however, a number of events that you don't want to hand to the user in the standard way. Examples of this include the KeyDown, KeyPress and KeyUp events. The reason
6
5355
by: sundarvenkata | last post by:
Hi All, I have a custom UserControl that is used as the list item in a listbox in my main WPF window. Is it possible to have key bindings that apply to every instance of the user control? For example, I have a keybinding Alt+R for a button in the UserControl. However when there are multiple instances of the UserControl in the listbox in my main WPF window, pressing Alt+R just shifts the keyboard focus to the button in the first user...
0
8413
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8740
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1733
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.