473,607 Members | 2,674 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

derived usercontrol

Is there any possibility to create a usercontrol deriving from an
abstract usercontrol?
I could only achieve it by editing the code from "MyControl :
System.Windows. Forms.UserContr ol" to "MyControl : MyAbstractContr ol" by
hand.
MyAbstractContr ol is declared abstract and it is derived from
System.Windows. Forms.UserContr ol.
If I do that, the controls cannot be displayed anymore in the designer.

What can I do to get around this problem

Thanks
Ferdinand
Dec 15 '05 #1
2 1659
Hi Ferdinand,

You will need to create a custom Designer for your Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but it takes a very long time,
and the bicycle has to *want* to change.

"Ferdinand Zaubzer" <fe************ ***@schendl.at> wrote in message
news:eQ******** *****@TK2MSFTNG P15.phx.gbl...
Is there any possibility to create a usercontrol deriving from an abstract
usercontrol?
I could only achieve it by editing the code from "MyControl :
System.Windows. Forms.UserContr ol" to "MyControl : MyAbstractContr ol" by
hand.
MyAbstractContr ol is declared abstract and it is derived from
System.Windows. Forms.UserContr ol.
If I do that, the controls cannot be displayed anymore in the designer.

What can I do to get around this problem

Thanks
Ferdinand

Dec 15 '05 #2
In order to design your derived control, the Designer must first create
an instance of the base control class at design time. Since you've
declared the base abstract, it can't do that, so it can't provide you
with a design surface to work on.

So, no, you can't design controls derived from abstract classes.

The closest you can come is to test the DesignMode property in your
base calss (after your constructor... typically in your OnLoad method
or something like that) and, if it's false, throw an
InvalidOperatio nException. That way you know that your base class will
never be instantiated at run time.

Dec 15 '05 #3

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

Similar topics

0
1373
by: Sebastian Ferreyra | last post by:
Hi, I'm writng a control derived from UserControl (let's call this control MyControl) that itself is meant to be derived further times. MyControl hosts a public collection of specialized non-GUI objects. This collection is therefore accesible from any controls derived from MyControl. Derived controls have to be able to add, change and remove objects from the collection.
2
2084
by: John B | last post by:
Hello I want to create a set of controls that have some common methods and properties. I was thinking that I should subclass the UserControl class and add these common features there and then base all my custom controls on this new MyUserControl Class. Is this the way to go? The MyUserControl would not actually have any UI component and should be abstract I think. Does this mena that I should not create the control by just selecting...
3
3956
by: ZhangZQ | last post by:
Supposing I have a class "UserControl1 : System.Windows.Forms.UserControl" in an Assembly "UI.dll", now I create an Application project and want to use the "UserControl1" in another AppDomain, private void CreateUIInAnotherDomain() { UI.UserControl1 ui = (UI.Cls)domain.CreateInstanceFromAndUnwrap(@".\UI.dll", "UI.UserControl1"); this.Controls.Add(ui);
4
2433
by: Dennis | last post by:
I am trying to set the default design proerties in a control I have derived from the Panel Class. I thought I'd found how to do it from the MSDN but the following line doesn't work: Inherits System.Windows.Forms.Design.ControlDesigner I get an error saying that the Type is not defined. I cut and pasted all the imports and line from the MSDN. Would appreciate any help.
7
1507
by: Dennis | last post by:
I have a control that inherits from the Panel Class. To this, I added a label which I want to use as a caption in my derived control. However, I can't get the label to show up in the panel. I tried a text box and it works fine. I've tried everything on the label from visible=True, BringToFront, etc. but I can't get it to show up. Is this a bug in VS or can one just not do this? -- Dennis in Houston
0
1027
by: Captain Sensible | last post by:
Hello! I created a master page and load usercontrols dynmamically during runtime. So far so good. But for getting a unique frame with functionality buttons like Add, save etc. I created a usercontrol "TemplateUserControl" with a table, within this table a placeholder, where I wanna put in another user control. So I get a unique look for all plus the benefit , that I can check the permissions for the content in the Template control ( in...
0
920
by: --== Alain ==-- | last post by:
Hi, i would like to improve the .NET control named ListView. for that i would need to display (quite) all properties and methods of ..NET ListView control to user and also to add my own. However i would like make this control (my control) available on toolbox tab (as it can be with UserControl way).
2
697
by: she_prog | last post by:
I have a class derived from UserControl. I need to serialize an object of this class, but only some properties of it, as not all properties are serializable (some of the properties coming from UserControl are like that). When serializing, how could I ignore all the properties coming from the UserControl class? I know there is XmlIgnoreAttribute, but how could I set it to every property of UserControl, as it is not my class? Thank you...
3
2965
by: zhaodapu | last post by:
I derived a panel class: public class DeskPanel : System.Windows.Forms.Panel Now I want to use the visual designer to add controls in MyPanel class. But I noticed that the visual designer didn't work. I try some other ways, and found the if i derived my panel from UserControl class it works. However, I thought deriving from Panel is more rational. I have several panels (such as calendar panel, contacts
0
8049
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
7985
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8463
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...
1
8128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8322
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...
0
5471
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
4013
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2461
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.