删除 .net ContextMenuStrip 填充
创建 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为设置 ShowShortCutKeys = False 将消除一些额外的右边距。
I think setting ShowShortCutKeys = False will get rid of some of the extra right margin.