Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7726175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:08:55+00:00 2026-06-01T05:08:55+00:00

Is there a simple way to increase the spacing between the menu item text

  • 0

Is there a simple way to increase the spacing between the menu item text and its shortcut key in a WinForms MenuStrip? As seen below, even the default template generated by VS looks bad, with the text “Print Preview” extending beyond the shortcut keys of other items:

MenuStrip

I’m looking for a way to have some spacing between the longest menu item and the start of the shortcut key margin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:08:56+00:00Added an answer on June 1, 2026 at 5:08 am

    An easy way to do it is to space out the shorter menu items. For example, pad the Text property of your “New” menu item to be “New               ” so that it has all the extra spaces at the end and that will push over the shortcut.

    Update

    I suggested automating this in code to help you out. Here’s the result of letting the code do the work for you:

    enter image description here

    I wrote the following code that you can call that will go through all the main menu items under your menu strip and resize all the menu items:

    // put in your ctor or OnLoad
    // Note: the actual name of your MenuStrip may be different than mine
    // go through each of the main menu items
    foreach (var item in menuStrip1.Items)
    {
        if (item is ToolStripMenuItem)
        {
            ToolStripMenuItem menuItem = (ToolStripMenuItem)item;
            ResizeMenuItems(menuItem.DropDownItems);
        }
    }
    

    And these are the methods that do the work:

    private void ResizeMenuItems(ToolStripItemCollection items)
    {
        // find the menu item that has the longest width 
        int max = 0;
        foreach (var item in items)
        {
            // only look at menu items and ignore seperators, etc.
            if (item is ToolStripMenuItem)
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)item;
                // get the size of the menu item text
                Size sz = TextRenderer.MeasureText(menuItem.Text, menuItem.Font);
                // keep the longest string
                max = sz.Width > max ? sz.Width : max;
            }
        }
    
        // go through the menu items and make them about the same length
        foreach (var item in items)
        {
            if (item is ToolStripMenuItem)
            {
                ToolStripMenuItem menuItem = (ToolStripMenuItem)item;
                menuItem.Text = PadStringToLength(menuItem.Text, menuItem.Font, max);
            }
        }
    }
    
    private string PadStringToLength(string source, Font font, int width)
    {
        // keep padding the right with spaces until we reach the proper length
        string newText = source;
        while (TextRenderer.MeasureText(newText, font).Width < width)
        {
            newText = newText.PadRight(newText.Length + 1);
        }
        return newText;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a simple way to see assigned shortcuts with given prefix? Something similar
Is there a simple way to have isometric projection? I mean the true isometric
Is there a simple way to work with C++ objects directly from C? I
Is there a simple way to convert MP3 to WAV in vb2005? what i
Is there a simple way or method to convert a Stream into a byte[]
Is there a simple way of redirecting serial port output to a file, that
Is there a simple way of rendering to a BufferedImage in Java3D? I know
Is there any (simple) way to get some control of the order in which
Is there some simple way to send out a ping-style message to a remote
I am trying to implement the event aggregator pattern in a simple way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.