Composite control of Winform in C #

Composite control

Image http://www.freeimagehosting.net/uploads/a51136603b.png

Howdy

I hope for help. I wanted to create the Composite Control shown in the screenshot above. As you can see in the screenshot, Parent Control is label 1; it contains child controls Label2, Label3 and Label4 and PictureBox, containing a predefined image.

I would like to include the above in a C # composite control with the following specifications:

The parent label, Label1, should generate a Click event. Label2, Label3, and Label4 controls must be assigned to tooltips in the MouseMove event, while the last Child Control, PictureBox must have both tooltips for MouseMove Event and Click Event.

Similarly, the locations of Label2, Label3, Label4, and PictureBox in the Parent Label1 control must be set as properties, as well as their texts and sizes.

How do I incorporate all of this into one composite control called AilmentLabel? Any advice or information is appreciated. Thank you very much.

+4
source share
2 answers

MSDN provides a very detailed description of how to do this. You should read the walkthrough: "Creating a composite control with C #"

+3
source

It looks like you want to create a "UserControl". It is just like any other control, but you can add controls to the surface. Then you will set the properties in the UserControl source, which will propagate the changes to the corresponding control:

public string Label1Text { get { return this.Label1.Text; } set { this.Label1.Text = value; } } ...etc... 

You can even expose Click events this way and let users subscribe to them. You can then drag this new control onto other surfaces of your window.

+1
source

All Articles