本文介绍了删除空白围绕ToolStripControlHost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试删除一个工具条控制主机控制在上下文菜单中托管日历控件周围的空白。请参阅附上的图片和代码。

I am trying to remove the white space around a toolstripcontrolhost control which hosts a calendar control in a contextmenu. See the attached image and code.

VB:

    Dim menuItem As ToolStripMenuItem = New ToolStripMenuItem("MyMenu")

    Dim calControl As New MonthCalendar

    Dim controlHost As ToolStripControlHost = New ToolStripControlHost(calControl)

    controlHost.Margin = Padding.Empty
    controlHost.Padding = Padding.Empty

    ContextMenuStrip1.Items.Add(menuItem)
    menuItem.DropDown.Items.Add(controlHost)

C#:

ToolStripMenuItem menuItem = new ToolStripMenuItem("MyMenu");

MonthCalendar calControl = new MonthCalendar();

ToolStripControlHost controlHost = new ToolStripControlHost(calControl);

controlHost.Margin = Padding.Empty;
controlHost.Padding = Padding.Empty;

ContextMenuStrip1.Items.Add(menuItem);
menuItem.DropDown.Items.Add(controlHost);

推荐答案

A ToolStripDropDown 在这种情况下可能工作得更好:

A ToolStripDropDown will probably work better in this scenario:

MonthCalendar calControl = new MonthCalendar();
ToolStripControlHost controlHost = new ToolStripControlHost(calControl);
controlHost.Margin = Padding.Empty;
controlHost.Padding = Padding.Empty;
ToolStripDropDown toolDrop = new ToolStripDropDown();
toolDrop.Padding = Padding.Emtpy;
toolDrop.Margin = Padding.Empty;
toolDrop.Items.Add(controlHost);

toolDrop.Show(this, location);

这篇关于删除空白围绕ToolStripControlHost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 06:12