Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ContextmenuStrip Width

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.

like image 812
Peymankh Avatar asked Aug 30 '26 03:08

Peymankh


1 Answers

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
like image 149
joshuapoehls Avatar answered Sep 04 '26 02:09

joshuapoehls



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!