在 Windows 窗体应用程序中禁用 MenuStrip 下拉菜单 [英] Disable MenuStrip Dropdown in Windows Forms Application

查看:32
本文介绍了在 Windows 窗体应用程序中禁用 MenuStrip 下拉菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在禁用 Windows 窗体菜单条中的父菜单选项.当您将鼠标悬停在它上面时,子菜单仍会打开.有没有办法禁用子菜单打开,或者我必须禁用所有子菜单项?

I am disabling the parent menu option in a Windows forms menustrip. When you hover over it, the submenu still opens. Is there a way to disable the submenu opening or do I have to disable all the submenu items?

推荐答案

我最终通过 DropDownItems 循环并在禁用主要项目后禁用它们.

I ended up looping through the DropDownItems and disabling them after I disable the main item.

for (int i = 0; i < this._menuOpen.DropDownItems.Count; i++)
{
    this.menuOpen.DropDownItems[i].Enabled = false;
}

这篇关于在 Windows 窗体应用程序中禁用 MenuStrip 下拉菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆