custom group controls
-
Heya, I'm having problems creating a custom group control (which I'll call XPanel for now). I'd like XPanel to be a user control consisting of several sub-panels, that the XPanel user can add their own child controls to. I have two problems with this: 1) If I add an event handler to the XPanel.ControlAdded event that transfers the added control to one of the sub-panels, I get an error in a message box at design time: "'child' is not a child control of this parent". This doesn't happen if I create and add the control at run-time. 2) How do I allow the sub-panels to be selectable at design time? Will I have to write my own design-time painting and interaction code? At the moment, the XPanel appears as a big indivisible unit when I add it to a form. Thanks in advance! Andy
-
Heya, I'm having problems creating a custom group control (which I'll call XPanel for now). I'd like XPanel to be a user control consisting of several sub-panels, that the XPanel user can add their own child controls to. I have two problems with this: 1) If I add an event handler to the XPanel.ControlAdded event that transfers the added control to one of the sub-panels, I get an error in a message box at design time: "'child' is not a child control of this parent". This doesn't happen if I create and add the control at run-time. 2) How do I allow the sub-panels to be selectable at design time? Will I have to write my own design-time painting and interaction code? At the moment, the XPanel appears as a big indivisible unit when I add it to a form. Thanks in advance! Andy
I've just tried and I can add sub-controls to 'XPanel' in the VS-designer without issue if I inherit XPanel from
Panel
instead ofUserControl
. NoControlAdded
event handling required. -
I've just tried and I can add sub-controls to 'XPanel' in the VS-designer without issue if I inherit XPanel from
Panel
instead ofUserControl
. NoControlAdded
event handling required.Hi Bob, Thanks! I think I wasn't clear about it, though - I have no problem inheriting XPanel from Panel and adding child controls, but that's not quite what I want. XPanel has N child panels S1..SN, that could look like this:
+-XPanel------------+ |...................| |.+-S1--+...........| |.|.....|...........| |.+-----+..+-S2--+..| |..........|.....|..| |..........+-----+..| |...................| +-------------------+
If the user of XPanel adds an instance to a form, I would like her to be able to add controls to XPanel.S1 or XPanel.S2, instead of to XPanel directly. Which is why I wanted to handle ControlAdded, so I could pass controls added to XPanel on to XPanel.S1 or XPanel.S2. Thanks again, Andy -- modified at 10:35 Monday 29th January, 2007 (got inheritance order wrong :)