Control derived from GroupBox not acting as a control container

  • Thread starter Thread starter Severino
  • Start date Start date
S

Severino

Hello,

I'm developing a .NET component that contains a control derived from the
GroupBox class in the following way:

public __gc class MyGroupBox : public System::Windows::Forms::GroupBox
{
...
}

all works correctly apart from the fact that MyGroupBox, once inserted into
a form, will not act as a control container but as a simple control: if I
put a Radio button inside this control and try to move it around at
design-time, the Radio button will not move accordingly: looking the form
code I can see that the Radio button has been added as a child of the form
instead of being added as a child of the GroupBox.
Is there something I should be aware of? Is there a turnaround for this?

Thanks in advance and Kind regards

Severino
 
Some further information about this problem:
I've discovered that the cause of this behaviour is the due to the fact of
having setup the Designer attribute for this control class in the way below:

[Designer(__typeof(MyGroupDesigner))]
public __gc class MyGroupBox : public System::Windows::Forms::GroupBox

the MyGroupDesigner class is defined as follows:

__gc public class MyGroupDesigner : public
System::Windows::Forms::Design::ControlDesigner
{
}

If I comment out the complete content of MyGroupDesigner class the problem
will still appear, while if I comment out the
[Designer(__typeof(MyGroupDesigner))] line, all works as espected.

Can somebody tell me what I'm currently missing?

Regards

Severino
 
Try

__gc class MyControlDesigner : public System::Windows::Forms::Design::ParentalControlDesigne

}

instead of

__gc class MyControlDesigner : public System::Windows::Forms::Design::ControlDesigne

}
 
Thank you very much for your help: the correct class name to derive from is
ParentControlDesigner but now all work as espected.

Regards

Severino
 
Also, derive from ComponentDesigner if you want components like the connection classes, menus, or timer.
 
Back
Top