menuStrip鼠标滑过自动弹出

 

 

 

 

在页面FormMain_Load里面添加如下注册事件:

            for (int i = 0; i < this.toolStrip1.Items.Count; i++) {
                this.toolStrip1.Items[i].MouseHover += new EventHandler(toolStrip1_MouseHover);
            }

添加方法:

       private void toolStrip1_MouseHover(object sender, EventArgs e) {
            if (sender is ToolStripDropDownItem) {
                ToolStripDropDownItem item = sender as ToolStripDropDownItem;
                if (item.HasDropDownItems && !item.DropDown.Visible) {
                    item.ShowDropDown();
                }
            }

        }

 

posted @ 2021-07-06 08:19  许宝  阅读(53)  评论(0编辑  收藏  举报