Vault of Thoughts

2006-07-11

Please visit my new blog at vaultofthoughts.net

A custom container control

I have made some research on how to create a container control - a control which works in a similar way as the Panel control does. There are three key thing you have to do in order to make it work:



  • Add ParseChildren(false) attribute

  • Add PersistChildren(true) attribute

  • Add Designer(typeof(PanelDesigner)) attribute where PanelDesigner is a custom class deriving from ContainerControlDesigner. I haven't tried it, but I suppose that using the ContainerControlDesigner in with Designer attribute would also do.


It's all. You do not have to add any more code. Since, the custom PanelDesigner does not require any code, the question arises - why do we need it? Shouldn't it be some kind of attribute?


A creative usage for such a control could be for example when you need a panel control which has some kind of static content, or maybe images as borders. You get the picture.

If you liked this article why not support its author by making a donation?

1 Comments:

  • Actually the Panel webcontrol uses a designer called PanelContainerDesigner.

    By Anonymous Anonymous, at 1:35 AM  

Post a Comment

<< Home