|
I have derived a class from UserControl and added severl methods and properties that are common through my entire C# project. After disigning the layout for most of my UserControls, I altered the code to use my new class as the base class.
The problem is this....even though I derrived my class from the original base class (UserControl), the designer is no longer rendering my controls when I open them. Is there any way to fix this?
If so, any and all help would be appreciated.
(Not sure if this is the correct forum, so if I need to move it, please let me know). Eric- Moved byJialiang Ge [MSFT]MSFTWednesday, September 16, 2009 6:37 AMmove to the designer forum. (From:Common Language Runtime)
-
|
| Eric Crammer Wednesday, September 16, 2009 4:47 AM |
Do you have one:
public class MyBaseControl : UserControl
{
...
}
? Or do you have several:
public class MyButton : Button
{
..
}
public class MyLabel: Label
{
...
}
//etc.
? If you have the latter, the UserControl designer is lost and therefore what you describe is probably normal. Or did I misunderstand?
MCP |
| webJose Wednesday, September 16, 2009 4:19 PM |
I have about 25 controls that all share some common functionality in them. I declared a base class similar to this:
public class MyBaseClass : UserControl {
}
I then derrive all of my controls as follows:
public class MyControl1 : MyBaseClass {
}
Is this incorrect? The designer is no longer able to render MyControl1
Eric |
| Eric Crammer Wednesday, September 16, 2009 4:56 PM |
OK, yes. That seems about right. Now, what exactly is your problem? Is it your problem that your controls derived from MyBaseClass are not showing or drawing in the surface of a form? Or is it your problem that your controls derived from MyBaseClass do not show a designer similar to the UserControl designer (one where you can drag controls to it and position them, etc.)? If it is the latter, check out this post: http://social.msdn.microsoft.com/Forums/en-US/winformsdesigner/thread/55a561bd-b22a-486d-b8d8-59f6612bb317. MCP |
| webJose Wednesday, September 16, 2009 5:05 PM |
I am using Visual Studio 2008. The error I get is as follows:
|
|
![]() |
|
To prevent possible data loss before loading the designer, the following errors must be resolved: |
|
|
|
|
|
|
|
|
|
![]() |
|
1 Error |
|
|
|
|
![]() |
|
Why am I seeing this page? |
|
|
|
|
|
|
I hope this gives you sufficient information. In this case, PioneerControlParent is my base class that derives from UserControl. Thanks!
Eric |
| Eric Crammer Wednesday, September 16, 2009 5:09 PM |
You have an error in your code that is preventing the operation to complete. Debug the design-time behavior of your user controls before moving on. To do this, you debug devenv.exe itself (another instance of Visual Studio). http://msdn.microsoft.com/en-us/library/5ytx0z24%28VS.80%29.aspx And set a designer to your base class to be the designer of the UserControl. Like the URL in my previous post shows.
MCP |
| webJose Wednesday, September 16, 2009 5:16 PM |
I think part of my issue is that I am build an app for a mobile device. I referenced the link you provided, and it looks like using an attribute for the base class may work. The problem is that I do not have access to the [Designer....] attribute in the .NETCF.
I may be stuck simply designing all the screens first, then changing my base class to my custom base class.
If you have any other ideas, I'd love to hear them.
Thanks Eric |
| Eric Crammer Wednesday, September 16, 2009 6:45 PM |
Hi Eric Crammer,
> I am build an app for a mobile device.
Do you mean the project is a Windows Mobile project? Windows Mobile project is quite different from Windows Forms project. If it is a Windows Mobile project, you’ll need to post the question on Smart Device Development forum.
Thank you for your understanding.
Sincerely,
Kira Qian
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! |
| Kira Qian Thursday, September 17, 2009 6:07 AM |
Hi Eric. Unfortunately, I have no experience with mobile devices. You should follow Kira's advise on this one. MCP |
| webJose Friday, September 18, 2009 3:37 PM |