删除 .net ContextMenuStrip 填充

发布于 2024-07-16 08:07:10 字数 961 浏览 4 评论 0原文

创建 ContextMenuStrip 时,所包含的控件周围有大量填充。 例如:

    Me.myMenu = New ContextMenuStrip
    'unset all obvious padding settings'
    Me.myMenu.ShowCheckMargin = False
    Me.myMenu.ShowImageMargin = False
    Me.myMenu.Margin = New System.Windows.Forms.Padding(0)
    Me.myMenu.Padding = New System.Windows.Forms.Padding(0)

    Dim addButton As New Button
    addButton.Size = New Size(60, 60)
    addButton.Text = "Button"
    Dim addControlHost As New ToolStripControlHost(addButton)

    Me.myMenu.Items.Add(addcontrolhost)

    Me.ContextMenuStrip = Me.myMenu

理想情况下,这会导致在光标位置弹出一个 60x60 按钮。 实际弹出的是这样的:

alt text http://img144.imageshack.us/img144 /8512/contextmenubutton.png

正如预期的那样,按钮就在那里,但是尽管没有边距、没有填充,并且将 Show*Margin 设置都设置为 False,但按钮周围有一个巨大的边框。

我可能错过了一些非常明显的东西,但是我怎样才能摆脱所有的白色边框,尤其是巨大的右侧边距?

When creating a ContextMenuStrip, there is a huge amount of padding around the contained controls.
For example:

    Me.myMenu = New ContextMenuStrip
    'unset all obvious padding settings'
    Me.myMenu.ShowCheckMargin = False
    Me.myMenu.ShowImageMargin = False
    Me.myMenu.Margin = New System.Windows.Forms.Padding(0)
    Me.myMenu.Padding = New System.Windows.Forms.Padding(0)

    Dim addButton As New Button
    addButton.Size = New Size(60, 60)
    addButton.Text = "Button"
    Dim addControlHost As New ToolStripControlHost(addButton)

    Me.myMenu.Items.Add(addcontrolhost)

    Me.ContextMenuStrip = Me.myMenu

This, ideally, would cause a 60x60 button to pop up at the cursor location.
What actually pops up is this:

alt text http://img144.imageshack.us/img144/8512/contextmenubutton.png

The button is there, as expected, but despite there being no margin, no padding, and having set both Show*Margin settings to False, there is a massive border around the Button.

I'm probably missing something blindingly obvious, but how can I get rid of all the white bordering, especially that huge right-hand margin?

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

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

发布评论

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

评论(1

╰沐子 2024-07-23 08:07:10

我认为设置 ShowShortCutKeys = False 将消除一些额外的右边距。

I think setting ShowShortCutKeys = False will get rid of some of the extra right margin.

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