0

I'm in the process of porting a legacy VB application to C#/Winforms. While the vast majority of the user interface is complete, I have a problem that I've not been able to solve after some digging. My form contains a bunch of group boxes, all identical (except for some identifier, e.g. group box name), each of which contains several controls. I have a context menu that pops up which allows me to open child forms which allow me to change some settings, etc. Each of these group boxes represents a physical object, which can be disabled. When I disable the group box, all the children of the box are then disabled or made invisible. When the group box is disabled, the context strip menu also changes so that some of the menu items on the context menu are disabled, and then the "Enabled" menu selection toggles between checked and unchecked, showing the current state. The problem is, when I disable one of the group boxes, the box is disabled, but the context menu no longer opens when I click on the group box. This isn't terribly surprising, but I'm trying to figure out how to disable the group box while keeping the context menu enabled all the time. I need to be able to disable one or more of these group boxes; the way things are, once I disable a group box I have no way of enabling it again, since the context menu no longer fires.

The old VB code manages to do this, but it's not terribly clear how and the code is more or less a mess I'd rather not spend time reverse engineering.

Thanks for any suggestions on how I can accomplish this. I suppose a work around might be to just make all the controls within the group box invisible, and then change the color of the group box to "appear" disabled.

4

1 回答 1

1

我通过简单地隐藏所有控件并更改框的颜色使其显示为禁用来解决了这个问题。

于 2012-08-23T16:29:51.653 回答