Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Can't design a User control if not inherited directly from UserControl
 

Can't design a User control if not inherited directly from UserControl

Hello

I have created a BasicUserControl in my project.

All my user controls inherits from this user control

MyProjectUserControl : BasicUserControl : UserControl


My problem is that the Visual Studio (2008) Designer does not "recognize" any of MyUserControls and I cant design them in the VS designer.

How can I bypass this?

Thanks for help
Best regards, Sergiu
Sergiu Dudnic  Monday, September 21, 2009 8:30 AM
I have no such problem. I did the following:

I added a new user control. I named it BaseControl. I then compiled the project.

After compiling, I added another user control. I named it MyNewControl. I opened the code and made it inherit from BaseControl instead of UserControl. I saved it. Whenever I open MyNewControl in Visual Studio, I see it as if it were the good old UserControl. I can add items visually by grabbing toolbox items, etc.

This designer behavior should be controlled by the DesignerAttribute attribute of your control class. Maybe you are using a custom designer? The following is the designer of the UserControl:

[Designer("System.Windows.Forms.Design.UserControlDocumentDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(IRootDesigner))]

That is, for .Net 2.0. I guess you can make it version-independent by removing the version, culture, and public key token parts.
MCP
webJose  Wednesday, September 23, 2009 1:01 PM
I have no such problem. I did the following:

I added a new user control. I named it BaseControl. I then compiled the project.

After compiling, I added another user control. I named it MyNewControl. I opened the code and made it inherit from BaseControl instead of UserControl. I saved it. Whenever I open MyNewControl in Visual Studio, I see it as if it were the good old UserControl. I can add items visually by grabbing toolbox items, etc.

This designer behavior should be controlled by the DesignerAttribute attribute of your control class. Maybe you are using a custom designer? The following is the designer of the UserControl:

[Designer("System.Windows.Forms.Design.UserControlDocumentDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", typeof(IRootDesigner))]

That is, for .Net 2.0. I guess you can make it version-independent by removing the version, culture, and public key token parts.
MCP
webJose  Wednesday, September 23, 2009 1:01 PM

You can use google to search for other answers

Custom Search

More Threads

• Showing Current Date and Time without using Timer in VB.Net 2005?
• Property value is not valid - Ambiguous match found
• Docking and AutoScroll
• MdiContainer background Color C#
• IPOD File Browser
• Text property
• VS2005 C# Textbox and Arial 8.25pt problem
• Property Filtering
• How do you implement the layout commands for IDesignerHost?
• problem with the collection control