开发者

Premature closing of hosted usercontrol in toolstrip menu

开发者 https://www.devze.com 2023-04-11 09:20 出处:网络
I\'m hosting a usercontrol in a tool开发者_JAVA技巧strip dropdown using the technique described here: http://windowsclient.net/blogs/faqs/archive/2006/07/12/how-can-i-add-a-user-control-to-a-toolstrip

I'm hosting a usercontrol in a tool开发者_JAVA技巧strip dropdown using the technique described here: http://windowsclient.net/blogs/faqs/archive/2006/07/12/how-can-i-add-a-user-control-to-a-toolstrip.aspx.

This technique works beautifully, except for the fact that the user control I'm hosting has several combo boxes. A few of those drop down outside of the usercontrol's surface. When I click on combo items outside of the usercontrol's surface, it closes the menu item (similar to if you drop down a menu and then click anywhere in the windows outside the menu).

Surely there's some way to prevent the tab strip drop down from closing when the combo's drop down item is selected.


I have found a solution to the problem. It's not terribly elegant, but it's functional. For the combos that extend beyond the usercontrol, I simply keep track of when they're open. I created my own ToolStripDropDown derived class which I assign as the dropdown. It then checks to see if either of the two combos is open and if they are, it overrides the OnClosing method of the dropdown and cancels the close. Seems to work fine without (so far) any unwanted side-effects.

0

精彩评论

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

关注公众号