by Amr Elsehemy
26. January 2008 08:49
This post is simple and neat, the goal now is to add some designer verbs, so lets get straight.
What is a Designer Verb?
A designer can use the DesignerVerb class to add menu commands to the shortcut menu for the component it provides designer support for in design mode. Designer verbs associate a menu item with an event handler. Designer verbs are provided to the design-time environment by the Verbs property of the IDesigner interface. More...
by Amr Elsehemy
25. January 2008 07:36
As I mentioned in introducing the Designer post that one of the designer powers is filtering the control members, filtering here means removing or adding members (Properties, Events or Attributes) to the DesignTime Environment in the PropertyWindow.
The IDesignerFilter interface has the methods that enable filtering the members that appear in the Design time PropertyWindow.
The IDesignerFilter interface has 6 methods for filtering.
Why for each Properties , Events and Attributes there is a Pre and Post Filter method?
More...
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. More...
by Amr Elsehemy
18. January 2008 11:15
In the previous post I gave a brief introduction on what is a UITypeEditor and what you can get from using it, this part I will show you how to implement one.
So here are the steps:
- Define a class that derives from System.Drawing.Design.UITypeEditor.
- Override GetEditStyle to return a supported UITypeEditorEditStyle.
- Override EditValue and pass any controls necessary to the IWindowsFormsEditorService.
- Override GetPaintValueSupported.
- Override PaintValue if the editor supports painting.
- Override IsDropDownResizable if the editor is resiazble.

Now we will go through the steps one by one, the example I will introduce here will be another ColorEditor, I will use the ColorWheel introduced and explained in this MSDN magazine article.
The final editor that we will make will look like this
More...
by Amr Elsehemy
17. January 2008 05:52
In the previous posts in this series I introduced how to use some basic and advanced Attributes and how to add an image for your control to appear in the toolbox and then I gave an introduction on TypeConverters and examples here and here on how to use the TypeConverters. Now I will give an introduction on how UITypeEditors used in design time.
First, what is a UITypeEditor anyway from MSDN :
The UITypeEditor class provides a base class that you can derive from and extend to implement a custom type editor for the design-time environment. Typically, your custom type editor interacts with the PropertyGrid control.
More...
by Amr Elsehemy
14. January 2008 10:16
The last post in the series I have showed you how to implement a custom TypeConverter and override some of the virtual methods from the base class.
In this post I'll show how to some more advanced examples on how to get the most of TypeConverters. First look at the strucure of the example.
More...
by Amr Elsehemy
12. January 2008 23:33
In the previous post I gave an introduction on common TypeConverters and how to use them, in this post I will show you how to implement custom TypeConverters for your own custom data types.
First, lets explore the TypeConverter base type virtual methods ...
| Method | Description |
| CanConvertFrom |
Returns a Boolean value indicating whether the converter can convert an object of the specified type to the type that this converter represents. |
| CanConvertTo |
Returns a Boolean value indicating whether the converter can convert an object to the specified type. |
| ConvertFrom |
Converts the specified value to the type represented by this converter. |
| ConvertFromInvariantString |
Converts the string representation of a value to a type that this converter represents, using the invariant culture, which is English. |
| ConvertFromString |
Converts the string representation of a value to a type that this converter represents, using the given culture. |
| ConvertTo |
Converts the given object to the specified type. |
| ConvertToInvariantString |
Converts the given object to a string, using the invariant culture. |
| ConvertToString |
Converts the given object to a string, using the specified culture. |
| CreateInstance |
Creates or recreates an object given a dictionary of property values. The dictionary contains property name-value pairs. |
| GetCreateInstanceSupported |
Returns a Boolean value indicating whether CreateInstance has been implemented. |
| GetProperties |
Returns a collection of PropertyDescriptor objects for the given object. |
| GetPropertiesSupported |
Returns a Boolean value indicating whether the given object supports properties. |
| GetStandardValues |
Returns a collection of standard values for the type that this converter represents. |
| GetStandardValuesExclusive |
Returns a Boolean value indicating whether the standard values are mutually exclusive. |
| GetStandardValuesSupported |
Returns a Boolean value indicating whether GetStandardValues is implemented. |
| IsValid |
Returns a Boolean value indicating whether the specified value is valid for the type that this converter represents. |
More...
by Amr Elsehemy
12. January 2008 11:57
I mentioned in my Introduction post of this series the TypeConverters
Overview: For those who don't know what is a TypeConverter you can expect that it is something responsible to convert between types, there are times when you need to convert from one data type to another. Type converters are classes that describe how a particular object converts to and from other data types. For example, to display a date on the screen(console, windows form, web ..) it will need to be converted to a string representation. Vice Versa is true, if there is a string value of a date that needs to be stored for example in database. Usually casting is enough when the types are simple. But with complex types, a better technique is used.
TypeConverters are classes that define how an object converts to and from other types. Which are used during design time for sting conversion ( used by the PropertyGrid ), also in runtime in validations and conversions.
So, first lets take a look on some of the Common .NET Type Converters that are already built for us to use.
All the following classes are in the System.ComponentModel and the System.Drawing namespaces.
- StringConverter
- BooleanConverter
- CharConverter
- CollectionConverter
- CultureInfoConverter
- DateTimeConverter
- EnumConverter
- ExpandableObjectConverter
- GuidConverter
- TimeSpanConverter
- ColorConverter
- FontConverter
- PointConverter
- RectangleConverter
- SizeConverter
And much more. More...
by Amr Elsehemy
8. January 2008 02:15
| Attributes | Applied To | Description |
| ToolboxBitmap |
Controls |
Allows you to specify an icon to represent a control in a container, such as the Microsoft Visual Studio Form Designer. |
» ToolboxBitmapAttribute if you want to redistribute your custom control you should use this attribute to add an icon to it.
[ToolboxBitmap(typeof(Button))]
public class ButtonEx : Button
This will show the default icon of the Windows.Forms.Button control, to add a custom icon you will use one of the other two ToolboxBitmapAttribute constructors, the first one accepts a string as the full path for the image, the second one with a string and a type this one is used more frequently.
[ToolboxBitmap(typeof(ButtonEx),"ButtonEx.png")]
public class ButtonEx : Button
Note: For this to work you need to be sure of 2 things:
- The image name would be exactly spelled as the type (control).
- Right click the image and make sure its BuildAction is Embedded Resource.
by Amr Elsehemy
7. January 2008 11:39
In my previous post I pointed out the most common used Attributes for Design Time Support. In this part I will point out some more Attributes that take advantage of the Design Time Environment.
| Attributes | Applied To | Description |
| DisplayName |
Properties & Events |
Specifies the display name for a property or an event. |
| ParenthesizeProperty |
Properties |
Indicates whether the name of the associated property is displayed with parentheses in the Properties window. |
| RefreshProperties |
Properties |
Indicates that the property grid should refresh when the associated property value changes. |
| NotifyParentProperty |
Properties |
Indicates that the parent property is notified when the value of the property that this attribute is applied to is modified. |
| ReadOnly |
Properties |
Specifies whether the property this attribute is bound to is read-only or read/write. |
| DesignOnly |
Properties |
Specifies whether a property can only be set at design time.
|
More...