How to: Adjust the Attributes, Events, and Properties of a Component in Design Mode
You can use your custom designer to modify the attributes, events, and properties of your component in design mode.
The following code example demonstrates how to create a custom designer that adjusts a component's attributes, events, and properties. A designer class called DemoControlDesigner is attached to a DemoControl class and performs the following operations:
-
Adds a property to the DemoControl class.
-
Removes a property from the DemoControl class.
-
Shadows a property of the DemoControl class.
-
Changes attributes of a DemoControl class property
-
Creates a component on the design surface and attaches an event handler.
You can change the attributes, events, and properties of your component in design mode by overriding the following methods on your designer:
The following code example demonstrates how to override the PreFilterProperties and
PostFilterProperties methods to change the properties and attributes of the DemoControl class.
When you make changes to the design-time aspects of a component, you need to rebuild the control project. In addition, if there is another Windows Forms project that is currently open and uses this component, you will probably need to refresh the project to see the changes. Typically, you need to close and reopen the design window containing the component.
Note
|
|---|
|
You must add a reference to the design-time assembly, System.Design.dll. This assembly is not included in the .NET Framework 4 Client Profile. To add a reference to System.Design.dll, you must change the project's Target Framework to .NET Framework 4. |
Note