开发者

How to close a DropDown menu before it opens if (something)

I have a DropDown menu with some items that should be accessible only after the user has configured something. I wanted to use the Enabled property but in my case it's impossible.

So, I was thinking about the DropDownOpening event. I would look if (IsConfigured == true) an开发者_高级运维d if it's false, I want to stop the opening process so that the DropDown menu does not open and show the items.

How could I do that ?

Thank you.


Without knowing much about your specific use case - and not even being a .NET developer - this does not sound right on a different level.

The dropdown list should know for itself whether it is active or not. Trying to interfere with its internal operation - which your idea seems to be IMHO - is usually not a good idea, and if at all possible a hack which will most certainly cause you trouble down the road.

Maybe you could elaborate more on why you think enabling/disabling the control as a whole does not work for you and a solution for that be found.


Why don't you just disable the right subitems on DropDownOpening? Isn't this what you actually want?


I would probably hook into whatever you need to be configured previously to set the dropdown menu to enabled or not.

So, if you're waiting for another drop down to have a selected value; hook into SelectedIndexChanged event for the first dropdown and then enable/disable your secondary dropdown as appropriate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜