views:

237

answers:

1

i am instantiating my own ToolStripButton and adding it to a contextmenustrip it pops up but the text gets cut off:

 string[] layouts = new string[]{"Test 1", "test 2", "test 3"}
            List<ToolStripButton> items = new List<ToolStripButton>();
            foreach (string layout in layouts)
            {
                ToolStripButton item = new ToolStripButton(layout, image, LayoutClicked);
                item.AutoSize = true;
                items.Add(item);
            }
            layoutMenus.Items.Clear();
            layoutMenus.Items.AddRange(items.ToArray());
            layoutMenus.Show(Cursor.Position.X, Cursor.Position.Y);

any idea why the text is getting cut off as the autosize property is true?

+1  A: 

Curious; I can reproduce this... a reall oddity (for me) is that setting the menu's .Width fixes it... but setting it to anything (it seems to ignore the value completely):

layoutMenus.Width = 800; // could be 20, or 100 and would appear the same

See if that works. It does for me, even though it makes no real sense.

Even:

layoutMenus.Width++;
layoutMenus.Width--;

leaves enough space, but

layoutMenus.Width = layoutMenus.Width;

doesn't (presumably it checks for non-changes and ignores whatever side-effects the above has).

Marc Gravell