dimanche 15 mars 2015

Custom Highlight area for ToolStripDropDownButton

I would like to change the ToolStripDropDownButton and specifically the border, when the cursor is above the dropDownButton, these "blue" highlighted area.


How can I get the size of the image used by the toolStripDropDownButton and make this border/highlighted area as big as the image? The image is also a rectangle with rounded borders, is it possible to paint the border like this? I've made an small example image for what i want.


http://ift.tt/1GJW4XJ


Currently i have this but i have a problem with getting the location of the image. Currently i just wrote Point.Empty instead. Is it even possible to do it with a new renderer?



public MainForm()
{
InitializeComponent();
toolStrip1.Renderer = new MyRenderer();
}

private class MyRenderer : ToolStripProfessionalRenderer
{
protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
{
Rectangle bounds = new Rectangle(Point.Empty, e.Item.Image.Size);
e.Graphics.FillRectangle(Brushes.Aqua, bounds);
}
}

Aucun commentaire:

Enregistrer un commentaire