当我在C#中从一个选定的DropDownButton移到另一个DropDownButton时,如何设

how to set the DropDownButton automatically dropdown when I move from one selected DropDownButton to another one DropDownButton in C#?
2020-10-18
  •  译文(汉语)
  •  原文(英语)

我试图在C#windown形式的statusStrip中创建一些DropDownButtons.通常,当我将光标移动到按钮上时,它不会下拉菜单项,仅当我单击DropDownButton时才下拉菜单项.

但是,问题出在我单击后DropDownButton1,它会下拉项目,但是当我将光标移到另一个DropDownButton2项目时,的项目DropDownButton2不会下拉!DropDownButton2单击后移动鼠标时,如何设置自动下拉项DropDownButton1?就像一般应用一样?

谢谢大家!

速聊1:
我们可以看一些代码吗?
速聊2:
请添加一个最小的示例,请参见:stackoverflow.com/help/mcve
速聊3:
抱歉,我没有尝试任何代码,我只是使用Design视图创建并添加DropDownButton和项目.
解决过程1

您可以使用ComboBox.DroppedDown属性,在MouseHover事件上将其设置为true

解决过程2

尝试这样的事情:

this.dropDown1.MouseHover += new System.EventHandler(this.dropDown1_MouseHover);



private void dropDown1_MouseHover(object sender, System.EventArgs e) 
{
    //Set the dropdown1 to dropped
    dropDown1.DroppedDown = true; 

    //Set the other dropdown to undropped
    dropDown2.DroppedDown = false;

}

有关更多信息,请添加更多代码!

I have tried to create few DropDownButtons inside a statusStrip in C# windown form. It's normal that when I just move the cursor to the button, it will not drop down the items, it only drop down the items only when I clicked the DropDownButton.

However the issue is after I clicked on DropDownButton1, it drops down the items, but when I move the cursor to another DropDownButton2, the items of DropDownButton2 will not drop down!! How can I set the items of DropDownButton2 automatically drop down when I move mouse after clicking DropDownButton1? Just like the general application?

Thanks all!

Talk1:
Can we see some code, please?
Talk2:
Please add a minimal example see :stackoverflow.com/help/mcve
Talk3:
sorry, I didn't try any code for it, I just use the Design view to create & add the DropDownButton & items..
Solutions1

you can use the ComboBox.DroppedDown property, set it to true on MouseHover event

Solutions2

Try something like this:

this.dropDown1.MouseHover += new System.EventHandler(this.dropDown1_MouseHover);



private void dropDown1_MouseHover(object sender, System.EventArgs e) 
{
    //Set the dropdown1 to dropped
    dropDown1.DroppedDown = true; 

    //Set the other dropdown to undropped
    dropDown2.DroppedDown = false;

}

For more info add more code!

转载于:https://stackoverflow.com/questions/30773919/how-to-set-the-dropdownbutton-automatically-dropdown-when-i-move-from-one-select

本人是.net程序员,因为英语不行,使用工具翻译,希望对有需要的人有所帮助
如果本文质量不好,还请谅解,毕竟这些操作还是比较费时的,英语较好的可以看原文

留言回复
我们只提供高质量资源,素材,源码,坚持 下了就能用 原则,让客户花了钱觉得值
上班时间 : 周一至周五9:00-17:30 期待您的加入