Question

I need to change the contextmenustrip width dynamically, by default the contextmenustrip width depends on the text length of the ToolstripmenuItems.

And BTW I really don't wanna redraw the control again!!!

Thanks in advance.

Was it helpful?

Solution

You need to set the ContextMenuStrip AutoSize property to false. Then you can set the Width property to whatever you want. When AutoSize is set to true, the Width property is ignored and is calculated dynamically.

Example:

Dim menu As New ContextMenuStrip()
menu.AutoSize = False
menu.Width = 100

OTHER TIPS

AutoSize does a VERY poor job of guessing at the "correct" size anyway. When TRUE, the menu is far wider than any of the text would need it to be.

When you set it manually... you also have to set the HEIGHT to be far less than you would expect... if you want it to display in the correct size menu.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top