我可以将图标设置为1x1或透明图标,但我不喜欢这种解决方案,因为用户仍然可以单击它。
如果是mdiParents mainMenuStrip,我可以这样做:
private void mainMenuStrip_ItemEventHandler(Object sender, ToolStripItemEventArgs e)
{
if (e.Item.Text == "")
{
e.Item.Visible = false;//This will hide any toolstrip items that do not have text... ex. the SystemMenu.
}
}但是UltraToolbarsManager.Toolbars没有这个事件。
仅当mdiChild表单未最大化时,才能将mdiChild的ShowIcon设置为false。
我还尝试重载mdiChild SizeChanged事件并遍历工具,看看是否能找到要隐藏的那个,但也不起作用:
private void MdiChild_SizeChanged(object sender, EventArgs e)
{
Form theForm = sender as Form;
switch (theForm.WindowState)
{
case FormWindowState.Maximized:
theForm.Icon = Icon.FromHandle(Properties.Resources.blank.GetHicon());
foreach (UltraToolbar ut in UltraToolbarsManager1.Toolbars)
{
if (ut.IsMainMenuBar)
{
foreach (ToolBase tb in ut.Tools)
{
//This collection does not contain the one I want to hide.
// maybe?
if (tb is MdiMergePlaceholderTool)
{
tb.SharedProps.Visible = false;
}
}
}
}
break;
}
}UltraToolbarsManager和UltraToolbar似乎没有任何事件可供我处理,以尝试删除合并到工具栏中的内容……
这正是我要问的问题..但它没有得到回答:http://www.infragistics.com/community/forums/t/33396.aspx
我认为这是另一个帖子建议的更新链接,但修改100个表单来继承对我来说不是一个选择:http://help.infragistics.com/Help/NetAdvantage/WinForms/2013.1/CLR4.0/html/Win_Creation_Filter.html
几种可能性:-在OnItemAdded事件中隐藏项目。-从UltraToolbar中删除图标。也许是在OnMerge事件中。-如果图标无法隐藏/删除,则取消上下文菜单的事件。-以某种方式获得对图标项目的引用将会很好。
提前感谢您的回复。
发布于 2013-06-12 19:20:14
查看提供的信息,我假设您使用的是我们的默认模式UltraToolbarManager,因为如果您使用的是功能区模式,那么您可以通过MDIChild窗体的属性ShowIcon隐藏系统图标。当时我们还没有实现这样的功能(除了功能区模式)来隐藏你的图标或SystemMenu,所以你有两个可能的选择来解决这个问题。选项1:您可以使用CreationFilter。例如:
public Form1()
{
InitializeComponent();
ultraToolbarsManager1.CreationFilter = new HideIcon();
}
class HideIcon : IUIElementCreationFilter
{
public void AfterCreateChildElements(UIElement parent)
{
}
public bool BeforeCreateChildElements(UIElement parent)
{
if (parent is PopupToolUIElement)
{
parent.Parent.ChildElements.Remove(parent);
}
return false;
}
}您可以在我们的论坛帖子中找到示例:http://www.infragistics.com/community/forums/t/33396.aspx
另一种可能的方法是,如果您实现:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern Int32 RemoveMenu(IntPtr hMenu, Int32 nPosition, Int32 wFlags);或
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("user32", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Auto)]
public static extern bool DestroyMenu(IntPtr menu);这样,您可能会在最大化MDIChild表单时销毁菜单,并在使用以下命令更改MDIChild表单状态时重新创建上下文菜单:
[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
public static extern IntPtr CreatePopupMenu();我认为解决这项任务的最佳选择可能是使用CreationFilter
如果您有任何问题,请与我联系
https://stackoverflow.com/questions/16866038
复制相似问题