Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

How to: Change the Spacing and Alignment of ToolStrip Items in Windows Forms

The ToolStrip control fully supports layout features such as sizing, the spacing of ToolStripItem controls relative to each other, the arrangement of controls on the ToolStrip, and the spacing of controls relative to the ToolStrip.

Because the default value of the AutoSize property is true, controls are sized automatically unless you set the AutoSize property to false.

To manually size a ToolStripItem

  1. Set the AutoSize property to false for the associated control.

    toolStripButton1.AutoSize = false;
    
  2. Set the Size property the way you want for the associated ToolStripItem.

To set the spacing of a ToolStripItem

  • Insert the desired values, in pixels, into the Margin property of the associated control.

    The values of the Margin property specify the spacing between the item and adjacent items in this order: Left, Top, Right, and Bottom.

    toolStripTextBox1.Margin = new System.Windows.Forms.Padding 
        (3, 0, 3, 0);
    

To align a ToolStripItem to the right side of the ToolStrip

  • Set the Alignment property to Right for the associated control. By default, Alignment is set to Left, which aligns controls to the left side of the ToolStrip.

    toolStripSplitButton1.Alignment = 
        System.Windows.Forms.ToolStripItemAlignment.Right;
    

To arrange ToolStrip items on the ToolStrip

Show:
© 2015 Microsoft