mouseover event for menustripitem
I have some menustrip Items in my menustrip.I want to set the color of the menustrip item when the mous开发者_如何学JAVAe is on the menustripitem.Is it possible to have mouseover event for a menustripitem.
Thanks in Advance.
You need to create your own renderer and assign the MenuStrip.Renderer property. Here's an example, it is going to need some work to look better:
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
menuStrip1.Renderer = new MyRenderer();
}
private class MyRenderer : ToolStripProfessionalRenderer {
protected override void OnRenderMenuItemBackground(ToolStripItemRenderEventArgs e) {
if (e.Item.Selected) {
e.Graphics.FillRectangle(Brushes.Bisque, e.Item.Bounds);
}
else base.OnRenderMenuItemBackground(e);
}
}
}
You should use MouseEnter event of menustripitem.
精彩评论