Inherited control with design mode capabilities

G

Guest

Hello

How can I make inherited control, which I can edit in design mode: add more
controls on it etc. Basically, I need a usercontrol, but it cannot by inherited
form UserControl class but from some another class (say GroupBox). If I inherit
directly form GroupBox, I loose design mode possibilities. I cannot add more
controls on it in design mode (well, I can add them, but it's different.
I cannot position and size it visually).

Is there a way to accomplish this?

Thanks, Stano
 
G

Guest

Hello

What you need to do is to write your own designer to it and attach it
to the new control. If you want to be able to drop other controls over
use ParentControlDesigner.

I'd suggest reading through:
http://windowsforms.net/articles/shapedesigner.aspx
--


This is not my problem. I probably did not describe my problem clearly, so
I will try it now. I use VS2005.

If I want to create my own control, standard way in VS is to add new UserControl.
Then in design mode of THIS CONTROL I can put more controls on it and in
code to add some methods, properties, events...

But I want to create a control, which is INHERITED form some other control,
I have to add "Inherited User Control". The problem is, that I can choose
only from some control to inherit from (it seems the only choices VS offers
me is some other UserControls). If I choose something, I can edit THIS inherited
control in design mode as standard UserControl - I can put other controls
on it, position it there and so on...

But I want to inherit from some other graphical control ... say GroupBox,
to have its properties immediately available in code, but this is not possible.
If I change inheritance of my class to GroupBox, I loose design mode possibilities.
I cannot put more controls on it and position and size them.
To be exact, I can put controls on it, but they act like nonvisual components.
I cannot size and position them visually. :(

For now the only way how to achieve what I want is to create ordinal UserControl
and put GroupBox on it (with Docking set to Fill), and create properties
to access properties of this groupbox. But this was just an example and I
would like to inherit directly form more complex visual controls and keep
visual editing of this control working.

And by visual editing I mean editing directly this control, not when it itself
is put on some form.

Thanks, Stano
 
S

Stoitcho Goutsev \(100\)

Stanislav,

The article that I suggested explains why the what you want to do is
imposible. UserControls and Forms are the only controls in the framework
that have root designer. That is you can open them in their own designer and
add more controls to them. The rest of the controls can be dropped over some
other control that has root designer (form or user control), but they cannot
be edited as a separate entity.
And for me it makes perfect sense.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top