Buck
Buck

Reputation: 599

Toolstrip Drop Down Button Not Large Enough

Well the answers from stackoverflow looked promising, but no luck yet. Also, I may not have quite enough experience yet to see it.

Simple I thought: I am looking for a larger drop down arrow in a ToolStripDropDownButton as an item in the collection. The tool strip drop down button is very small. I would like it to be 3 times the current size. Slightly larger would be of benefit as well. The drop down, when selected, reveals a menu of items.

Is it possible to use the ToolStripRenderer or a user control to get this as desired (unless there is a property I do not see) or ?? I am not that familiar with custom controls in a Winforms environment, so any help with snippets or direction would be helpful. In other words, wondering, if a user control is needed, what do I need to make it work for this scenario? That said, I am looking for any solution that will work. Thanks for any help/ideas!!!!

Upvotes: 1

Views: 2286

Answers (2)

LarsTech
LarsTech

Reputation: 81610

Try making your own Renderer and override the OnRenderArrow method:

public class MyRenderer : ToolStripProfessionalRenderer {
  protected override void OnRenderArrow(ToolStripArrowRenderEventArgs e) {    
    if (e.Item.GetType() == typeof(ToolStripDropDownButton)) {
      Rectangle r = e.ArrowRectangle;
      List<Point> points = new List<Point>();
      points.Add(new Point(r.Left - 2, r.Height / 2 - 3));
      points.Add(new Point(r.Right + 2, r.Height / 2 - 3));
      points.Add(new Point(r.Left + (r.Width / 2),
                           r.Height / 2 + 3));
      e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
      e.Graphics.FillPolygon(Brushes.Black, points.ToArray());
    } else {
      base.OnRenderArrow(e);
    }
  }
}

Then apply it to the ToolStrip:

toolStrip1.Renderer = new MyRenderer();

You may have to change the button's AutoSize property to false and set the width of the button yourself to get the proper space.

enter image description here

Upvotes: 2

rory.ap
rory.ap

Reputation: 35260

You can change the size of the button by setting the AutoSize property to false and then setting the Size property to what you need. As far as making the arrow bigger, I don't think you can do that, but at least it will make the button bigger.

Upvotes: 1

Related Questions