using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication3
{
class clsLabel : System.Windows.Forms.Label
{
protected override void OnMouseDown(System.Windows.Forms.MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
ContextMenuStrip ctm = new ContextMenuStrip();
MenuItem itmFont = new MenuItem();
itmFont.Name = "itmFont";
itmFont.Text = "Change Font";
itmFont.Click += new EventHandler(itmFont_Click);
MenuItem itmColor = new MenuItem();
itmColor.Text = "Change Color";
itmColor.Name = "itmColor";
itmColor.Click += new EventHandler(itmColor_Click);
ctm.Items.Add("itmFont");
ctm.Items.Add("itmColor");
this.ContextMenuStrip = ctm;
}
}
void itmColor_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.Font = Font;
if (fd.ShowDialog() == DialogResult.OK)
{
Font = fd.Font;
}
//throw new Exception("The method or operation is not implemented.");
}
void itmFont_Click(object sender, EventArgs e)
{
FontDialog fd = new FontDialog();
fd.Font = Font;
if (fd.ShowDialog() == DialogResult.OK)
{
Font = fd.Font;
}
//throw new Exception("The method or operation is not implemented.");
}
}
}