Custom Controls Design Time Support Part 9: Introducing the Designer

by Amr Elsehemy 20. January 2008 00:55

What is a Designer?

Designers are objects that have the ability to modify a component’s design time behavior on a
design surface. A designer can display a component’s user interface as well as allow property
changes to the component. It can also provide other services and perform additional processing
specific to the component it is associated with.

What is a Designer Capable of?

  1. Filtering Properties in a control.
  2. Add commands in the control context menu during design time.
  3. Adding a smart tag to the control.
  4. much more...

Designer Hierarchy

Desginer Hierarchy

Any .Net designer will have to implement the System.ComponentModel.Design.IDesigner interface, two other Interfaces that extend the IDesigner are the IRootDesigner and the ITreeDesigner.

IRootDesginer : It indicates the root designer. A root designer is simply
a top-level designer for other designers.

Ofcourse windows controls are totally different than web controls, as the first ones paints pixels and the other renders HTML, so the designers too are different. There are 3 main Root Designers, one for Web designer System.Web.UI.Design.WebFormsRootDesigner , one for a Windows designer System.Windows.Forms.Design.DocumentDesigner which is the base for Windows Forms and User Controls, and the last one appears when building other controls System.Windows.Forms.Design.ComponentDocumentDesigner.

ITreeDesigner : Provides support for building a set of related custom designers.

No one will ever need to implement this interface for your Designers, all designers can use the base System.ComponentModel.Design.ComponentDesigner which is the base Designer for all web and all windows designers.

The HtmlControlDesigner is the most suitable base class for any web control designer.

The System.Windows.Forms.Design.ControlDesigner is the most suitable base class for any windows control designer.

As always to attach a Designer to the control you need use an Attribute.

[Designer(RoundButtonDesigner)]
public class RoundButton : Button

So next parts I will show common designer features for both web and windows controls, then show web only and windows only designer features.

Tags: , , ,

Design Time Support

Comments

1/27/2008 10:30:50 AM #

flobow

Thank you for your Custom Control Tut Serie.It has a very high Quality and is very good to understand.

It Helps me a lot and i didn't find a better tutorial. I searched a lot for this topic and only find snippets..

I hope you'll make more tuts of this thank you!

flobow |

1/27/2008 10:38:07 AM #

Amr

@flobow
Thank you very much for this comment, made my day.
Promise you will like the next parts too.

Amr Egypt |

Comments are closed

About the author

Amr Elsehemy
MCSD C#.Net,
MCTS Sql 2005,
MCPD Enterprise
avatar
E-mail me Send mail

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar