Control from scratch ?
-
YES You got that right. And is for WinForm.(i'll edit my original post) thanks and sorry for omitting it.
Okay, well if I were you then, I would start by looking to inherit from ContainerControl (that's what UserControl inherits from). Then, you need to evaluate whether or not you need the features that you get specifically from the UserControl (e.g. Border).
Chill _Maxxx_
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
How to create a control from scratch? (for WinForm applications) NOT inherit/extend UserControl. I want to create something totally new. A good example is the timer control properties - i bet that is not an extension from Usercontrol. Something similar i need. { I just want to create(fromScratch),visualize and use a NEW control with its properties (and events). } For example: I want a Control named "Car" Properties: wheels,doors,windows,lights,sounds,color,name,class,subclass,etc Events: Speed,Stop, Accelerate,Brake,click, collide,touch, lightsOn,soundOn,noWheels,etc And nothing more than this ! Thanks.
-
How to create a control from scratch? (for WinForm applications) NOT inherit/extend UserControl. I want to create something totally new. A good example is the timer control properties - i bet that is not an extension from Usercontrol. Something similar i need. { I just want to create(fromScratch),visualize and use a NEW control with its properties (and events). } For example: I want a Control named "Car" Properties: wheels,doors,windows,lights,sounds,color,name,class,subclass,etc Events: Speed,Stop, Accelerate,Brake,click, collide,touch, lightsOn,soundOn,noWheels,etc And nothing more than this ! Thanks.
-
How to create a control from scratch? (for WinForm applications) NOT inherit/extend UserControl. I want to create something totally new. A good example is the timer control properties - i bet that is not an extension from Usercontrol. Something similar i need. { I just want to create(fromScratch),visualize and use a NEW control with its properties (and events). } For example: I want a Control named "Car" Properties: wheels,doors,windows,lights,sounds,color,name,class,subclass,etc Events: Speed,Stop, Accelerate,Brake,click, collide,touch, lightsOn,soundOn,noWheels,etc And nothing more than this ! Thanks.
Eddy is right. If you want to build a control from scratch you inherit from either Control or Component. UserControl is normally used when you want to build a new control from a mash up of other controls, like a button and textbox.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak -
-
Okay, well if I were you then, I would start by looking to inherit from ContainerControl (that's what UserControl inherits from). Then, you need to evaluate whether or not you need the features that you get specifically from the UserControl (e.g. Border).
Chill _Maxxx_
CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier -
Ok, and if i choose from Control to inherit(it's easier), then how I hide the rest of the properties showing in my Properties window?
You don't; they're inherited and required for the correct working of a control. Without them, you can't call it a control. You can hide properties using a hack, but that's all it is - a hack. It doesn't mean that the properties aren't accessible.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
You don't; they're inherited and required for the correct working of a control. Without them, you can't call it a control. You can hide properties using a hack, but that's all it is - a hack. It doesn't mean that the properties aren't accessible.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
How to create a control from scratch? (for WinForm applications) NOT inherit/extend UserControl. I want to create something totally new. A good example is the timer control properties - i bet that is not an extension from Usercontrol. Something similar i need. { I just want to create(fromScratch),visualize and use a NEW control with its properties (and events). } For example: I want a Control named "Car" Properties: wheels,doors,windows,lights,sounds,color,name,class,subclass,etc Events: Speed,Stop, Accelerate,Brake,click, collide,touch, lightsOn,soundOn,noWheels,etc And nothing more than this ! Thanks.
+ I have another problem = it seem that i can not add new events- well,working events. here is what i did so far:
public event EventHandler textchange2;
If i insert only this line in my "Car" control object , it will appear in events list when the new control will be added. The rest of the code is over my head... >>>
protected virtual void ontextchange2(EventArgs e)
{
EventHandler handler = textchange2;
if (handler != null) handler(this, new EventArgs());
} -
then, yes, i'm very interested on it- can you give me an example on how to do it? Please, and thanks.
http://stackoverflow.com/questions/1875401/how-to-hide-an-inherited-property-in-a-class-without-modifying-the-inherited-cla/4892913#4892913[^] FWIW; it's a "worst" practice. It does not add any functionality, does not add any value, and only introduces more code - code that needs maintenance, could contain bugs, and which is only used by the programmer that's using your component.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]