-->

Why am I getting a vertical line on toolstrip?

2019-01-28 09:46发布

问题:

I have two Windows Forms toolstrips that contain some controls on a form. However, for some strange reason, they contain a vertical line on the right hand side. I cannot find any property to remove them and I cannot find any other information on how to get rid of them online.

Can anyone help? Thanks in advance.

回答1:

It's the border of the toolstrip. Meant to give a clear separation between multiple adjacent tool strips. Changing its RenderMode property to System would be one way to get rid of it, albeit that this changes the look-and-feel. Or you can write your own renderer to get rid of it. A C# example:

    public Form1() {
        InitializeComponent();
        toolStrip1.Renderer = new MyRenderer();
    }
    private class MyRenderer : ToolStripProfessionalRenderer {
        protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) {
            // Do nothing
        }
    }