1. Create a User control project
2. Note the following line
private void InitializeComponent ()
{
components = new System.ComponentModel.Container ();
//this. AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
}
public partial class Exlabel:label
{
Public Exlabel ()
{
InitializeComponent ();
This. Click + = new EventHandler (Exlabel_click);
}
protected override void Onmouseenter (System.EventArgs e)
{
Base. Onmouseenter (e);
This. ForeColor = Color.Black;
This. BackColor = Color.White;
This. Font = new Font (" Arial ", 10F, Fontstyle.underline);
}
protected override void OnMouseLeave (System.EventArgs e)
{
Base. OnMouseLeave (e);
This. ForeColor = Color.White;
This. BackColor = Color.Black;
This. Font = new Font (" Arial ", 10F, Fontstyle.regular);
}
private void Exlabel_click (object sender, EventArgs e)
{
This. ForeColor = Color.magenta;
This. BackColor = Color.Blue;
}
Extended Control Properties