上下文菜单条带宽度

发布于 2024-07-15 13:20:59 字数 134 浏览 2 评论 0原文

我需要动态更改 contextmenustrip 宽度,默认情况下 contextmenustrip 宽度取决于 ToolstripmenuItems 的文本长度。

顺便说一句,我真的不想再次重绘控件!

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

终遇你 2024-07-22 13:21:00

您需要将 ContextMenuStrip AutoSize 属性设置为 false。 然后您可以将 Width 属性设置为您想要的任何值。 当 AutoSize 设置为 true 时,Width 属性将被忽略并动态计算。

例子:

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

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
美煞众生 2024-07-22 13:21:00

无论如何,AutoSize 在猜测“正确”尺寸方面做得非常糟糕。
当为 TRUE 时,菜单比任何文本所需的都要宽。

当您手动设置时...您还必须将 HEIGHT 设置为远小于您的预期...如果您希望它显示在正确大小的菜单中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文