Browse by Tags
All Tags » Custom Controls » Custom Designers (RSS)
Sorry, but there are no more tags available to filter with.
-
|
Override the InitializeNewComponent method on the ComponentDesigner attached to your control. This method is run the first time a control or component is added to the design surface. The corresponding InitializeExistingComponent is called when a control...
|
-
|
The following HatchStyleEditor class draws a graphical representation for values in the HatchStyle enumeration. HatchStyleEditor is derived from UITypeEditor and ovverides the GetPaintValueSupported method and returns true. GetPaintValueSupported indicates...
|
-
|
Add a TypeConverter attribute to your class type to tell the Property Browser it should be expandable. [ TypeConverter( typeof( ExpandableObjectConverter ) ) ] public class MyClass { /* ... */ } Shawn Burke, Microsoft
|
-
|
You can do this but it's not as simple as using an attribute. If you want to modify the property names for your component, you have to interact with the reflection mechanism that the grid is using by implementing ICustomTypeDescriptor. The grid operates...
|
-
|
Use this custom editor attribute for the property that is of the StringCollection type (this can be used for other Collection types too if you want to allow entry of strings into the collection during design-time). Editor( "System.Windows.Forms.Design...
|
-
|
This is usually a problem if you have a custom collection type MyCollection which itself can take items of type MyCollection. This is a problem because a single instance of a UITypeEditor is used by the framework irrespective of how many types and instances...
|
-
|
The default CollectionEditor will allow the user to add objects of type returned by your collection's indexer method. You can make this CollectionEditor allow your user to pick the type of object to add by deriving from CollectionEditor and making...
|
-
|
The string "(Collection)" is coming from the TypeConverter on that property, which is CollectionConverter. You can modify the string as shown here: [ TypeConverter( typeof( CustomCollectionConverter ) ] public class CustomCollection : SomeBaseCollection...
|
-
|
You normally need this support when your control is parented by another custom Container Control that manages the location and size of your Control. You can prevent resizing by overriding this method in your custom ControlDesigner class: protected override...
|
-
|
You can subscribe to the SelectionChanged event in your control designer. using System.ComponentModel.Design; public class CustomContainerDesigner : ParentControlDesigner { private bool iamSelected; public override void Initialize( IComponent component...
|
-
|
Override OnPaintAdornments in your Control Designer. This will be called after the Control has painted. A good example is when you have a Control that has its border style set to None, and you want to draw a dummy border in the designer. protected override...
|
-
|
The design-time will forward the MouseEnter and MouseLeave messages to your control by default. The MouseMove message is blocked by the designer. You can get MouseDown and MouseUp messages in your control if you override GetHitTest method in your designer...
|
-
|
Override the DrawGrid property in the custom designer: public class CustomContainerDesigner : ParentControlDesigner { protected override bool DrawGrid { get { return disableDrawGrid ? false : base.DrawGrid; } } } Contributed from George Shepherd's...
|
-
|
To restrict your Container Control to parent only certain types of controls, override as follows in your designer: public class CustomContainerControlDesigner : ParentControlDesigner { public override bool CanParent( Control control ) { return control...
|
-
|
You have to store a reference to the DesignerVerb instance you create to represent the custom verb. You can then update the state of the verb through this reference. Here is an example: public class CustomControlDesigner : ParentControlDesigner { private...
|
-
|
You need to create custom "Verbs" for your Component or Control designer. This will make your verbs show up in the property browser and in the designer context menu. The designer generates an event when the user selects a verb, and you can handle...
|
-
|
You need to use a second instance of Visual Studio .NET to debug the one that's running the code. Put your control on a form in VS.NET. Start a second instance of VS.NET. Choose the Debug | Processes menu item. Double-click devenv.exe and choose Common...
|
-
|
Here are a couple of articles that discuss custom designers. Writing Custom Designers for .NET Components by Shawn Burke in the MSDN Library. .NET Shape Library: A Sample Designer by Brian Pepin on www.windowsforms.net . Contributed from George Shepherd's...
|
-
|
The CollectionEditor allows adding and removing items from a collection at design time. If the items in this collection implement IComponent or if they are derived from Component, the items in your collection can be persisted in code. Download collectioneditorsample...
|
-
|
Sometimes you might want to let the designer serializer serialize the changes in base fields via a property rather than the field itself using the AccessedThroughProperty attribute in the System.Runtime.CompilerServices namespace. public class CustomForm...
|
-
|
It is normal to have properties in your control or component whose default values are inherited from a base class control or component. In such cases you will normally prevent the designer from storing the property's value in code (using either DefaultValue...
|
-
|
You have to set DesignerSerializationVisibility attribute on the property whose type is a strongly-typed collection to Content. You have to ensure the collection is created at statup or on demand. In order to support serialization of items that do not...
|
-
|
You can do this by creating the editor yourself rather than allowing TypeDescriptor to do it as follows. First, shadow the property you care about in your designer: protected override void PreFilterProperties( IDictionaryProperties props ) { PropertyDescriptor...
|
-
|
Implement the ICustomTypeDescriptor interface on the control, and provide a PropertyDescriptor for the property that changes its return value for the IsReadOnly method. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Set this attribute for the property: [ RefreshProperties( RefreshProperties.Repaint ) ] Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Parse through all the Controls in the designer and call TypeDescriptor.Refresh() on them. From inside your custom IDesigner implementation: private void UpdateExtendedProperties() { IDesignerHost idh = GetService( typeof( IDesignerHost ) ) as IDesignerHost;...
|
-
|
Subscribe to IDesignerHost.LoadComplete event. Make any changes to the designer host (like adding or deleting components) only after this event, or else the design document will not be made "dirty". IDesignerSerializationManager.SerializationComplete...
|
-
|
You can provide IntelliSense support for your type and its members by providing XML comments in code as follows: using System.Windows.Forms; /// <summary> /// Summary description for CustomForm. /// </summary> public class CustomForm : Form...
|
-
|
You can use the menu selection Format | Move To Front or Format | Send To Back to change the z-order and update your docking. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
Use the MergableProperty attribute with a value of false. This will prevent your Property from being edited as part of a group in the designer. Contributed from George Shepherd's Windows Forms FAQ
|
-
|
I can't get the Windows Forms designer to notice changes to a nested component when the user sets properties on it through the property grid. I marked the property with the DesignerSerializationVisibility.Content attribute and all works perfectly...
|
-
|
I am having a problem with a custom control I created in Visual Studio 2005. After the control is added to a Form, the created Initializer code is incomplete and I have to finish it by hand. One of my properties is a class that implements IList. When...
|