have Googled and cannot find out how to make a ToolStripSeparator "draw" an horizontal line in a toolbar that is aligned vertical.
The separator is drawn vertically which makes it awful.
开发者_如何学CEg.
* - item*
* | <- separator * *when it should be
*
* - <- separator * *You can create your own ToolStripRenderer and override the OnRenderSeparator to draw the line yourself.
protected override void OnRenderSeparator(ToolStripSeparatorRenderEventArgs e)
{
using (var pen = new Pen(borderColor))
{
e.Graphics.DrawLine(pen, 5, e.Item.Size.Height / 2, e.Item.Size.Width - 5, e.Item.Size.Height / 2);
}
}
Then you set the Renderer
property of your toolstrip to the renderer you just made.
toolStrip.Renderer = new MyToolStripRenderer();
精彩评论