views:

268

answers:

1

Hi, 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.

Eg.
* - item

*
*
| <- separator
*
*

when it should be

*
*
- <- separator
*
*

+1  A: 

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();
J. Steen