public class ToolStripEnhancedMenuItem : ToolStripMenuItem
{
protected override void OnClick(EventArgs e)
{
}
}
protected override void OnPaint(PaintEventArgs e)
{
if ((CheckMarkDisplayStyle == CheckMarkDisplayStyle.RadioButton))
{
Size radioButtonSize = RadioButtonRenderer.GetGlyphSize(e.Graphics, RadioButtonState.CheckedNormal);
int radioButtonX = ContentRectangle.X + 3;
int radioButtonY = ContentRectangle.Y + (ContentRectangle.Height - radioButtonSize.Height) / 2;
CheckState state = this.CheckState;
if (state == System.Windows.Forms.CheckState.Checked)
{
if ((this.Text.Contains(" ")) && (!this.Text.Contains("*")))
{
DrawCircle(e.Graphics,Color.Black);
finalCheckedMenuItem = this;
}
}
else
{
if (this.Text.Contains("*"))
{
DrawCircle(e.Graphics, Color.White);
this.Checked = false;
}
}
e.Graphics.DrawString(this.Text, this.Font, new SolidBrush(Color.Black), new Rectangle(new Point(radioButtonX, radioButtonY), this.Size), new StringFormat());
}
}
I painted the circle in the left of ToolStripEnhancedMenuItem. so i want to use OnClick method to erase it. It's the reason of why i'm want to use graphics in OnClick method.