Skip to content

July 28, 2015

PowerShell WinForm ToolStrip Bug Workaround

There is a known bug with the Tool Strips in Windows Forms. The issue is that when using the renderer, you will see a white border around your ToolStrip. Microsoft has stated that they will not be fixing the bug, however there is a C# workaround by overloading the method.

If you are using PowerShell to generate your Winforms, the fix is slightly different. In order to override this method for the fix, you must add the C# code to your PowerShell script by using the Add-Type cmdlet.  Once the Type is added you can assign the object to $ToolStrip.Renderer.


# C# Code
= @’
using System.Windows.Forms;
public class CustomSystemRender : ToolStripSystemRenderer
    public CustomSystemRender() { }
    protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e)

# Compile and add the code into script
-ReferencedAssemblies System.Windows.Forms -TypeDefinition $TypeCustomSystemRender -WarningAction SilentlyContinue

# Apply the Override to a ToolStrip
= New-Object System.Windows.Forms.ToolStrip
$ToolStrip.Location = New-Object System.Drawing.Point 10, 40
$ToolStrip.RenderMode = “System”
$ToolStrip.Renderer = New-Object CustomSystemRender


Read more from PowerShell

Share your thoughts, post a comment.


Note: HTML is allowed. Your email address will never be published.

Subscribe to comments