Change the BackColor of the ToolStripSeparator control

I just pointed my separators’ Paint event to this custom proc:

    private void mnuToolStripSeparator_Custom_Paint (Object sender, PaintEventArgs e)
    {
        ToolStripSeparator sep = (ToolStripSeparator)sender;

        e.Graphics.FillRectangle(new SolidBrush(CUSTOM_COLOR_BACKGROUND), 0, 0, sep.Width, sep.Height);

        e.Graphics.DrawLine(new Pen(CUSTOM_COLOR_FOREGROUND), 30, sep.Height / 2, sep.Width - 4, sep.Height / 2);

    }

Where the CUSTOM_COLOR_FOREGROUND is a solid/named Color, such as Color.White for example.

Leave a Comment