Skip to main content

Classic View

  • 3 minutes to read

Property Grid - Classic View

The Classic View emulates the Properties window UI in Visual Studio. This view type supports the following features:

  • Expandable category rows
  • Multi-editor rows
  • Custom editors
  • Custom draw for property values

To activate the Classic View, set the PropertyGridControl.ActiveViewType property to Classic.

Tip

Run the following demo to see the Classic View: Property Grid module in the XtraVerticalGrid MainDemo. Office View is the default view in the demo. To switch to Classic View, right-click the Property Grid and select Use Classic view in the context menu.

Multi-Editor Rows

MultiEditorRow displays multiple properties (and their corresponding editors).

Property Grid - Multi-Editor Row

Use the Property Grid Designer to create multi-editor rows.

Property Grid - Add Multi-Editor Row

Use the MultiEditorRow.PropertiesCollection property to add properties to the row. You can specify the property caption, bound field name, etc.

Property Grid - Properties Collection

The code below adds a multi-editor row to the Property Grid.

MultiEditorRow meRow = new MultiEditorRow();
meRow.PropertiesCollection.Add(new MultiEditorRowProperties() { FieldName = "Name", Caption = "Full Name" });
meRow.PropertiesCollection.Add(new MultiEditorRowProperties() { FieldName = "Category", Caption = "Product Category" });
meRow.PropertiesCollection.Add(new MultiEditorRowProperties() { FieldName = "Color", Caption = "Color" });
propertyGridControl1.Rows.Add(meRow);

Custom Draw Property Values

To custom paint a property value, complete the following steps:

The code below shows how to draw an angle.

Editor supports the representation of an object's value

Implement the virtual (Overridable in VB) UITypeEditor.PaintValue and UITypeEditor.GetPaintValueSupported methods to paint a property value. For more information on how to implement a custom editor, see the following help topic: UITypeEditor.

propertyGridControl1.OptionsView.AllowPaintValue = true;

public class SelectedObject {
    //The Editor attribute specifies the editor that users can utilize to edit the property value.
    [EditorAttribute(typeof(AngleEditor), typeof(System.Drawing.Design.UITypeEditor))]
    public double Angle { get; set; }
}

public class AngleEditor : System.Drawing.Design.UITypeEditor {
    // Override this method to paint the property value.
    public override void PaintValue(System.Drawing.Design.PaintValueEventArgs e) {
        //...
    }
    // Returns whether the editor can paint the property value.
    public override bool GetPaintValueSupported(System.ComponentModel.ITypeDescriptorContext context) {
        return true;
    }

    //...
}