Edit in place settings.

Namespace: Dapfor.Net.Ui
Assembly: Dapfor.Net (in Dapfor.Net.dll) Version: (


public sealed class GridEditInPlace
Visual Basic
Public NotInheritable Class GridEditInPlace
Visual C++
public ref class GridEditInPlace sealed
type GridEditInPlace =  class end


To edit value in Cell, the data object must implement the Set- property, and the Column must be editable. If this two conditions are true, then the Grid looks for the editor in the next order:


 Copy imageCopy
//Example of an easy drop-down editor where the end-user can click on the push button
public class CustomEditor : UITypeEditor
    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
        // Uses the IWindowsFormsEditorService to display a drop-down UI in the grid. (See more System.Drawing.Design.UITypeEditor)
        IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

        //The result to be returned
        object result = value;

        //Create some UI control
        Button button = new Button();
        button.Click += delegate
            //result = ... <new value>
        //Do edit in place in the editor service. If the end user clicks on the button, then the callback will be called.

        return result;

    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
        //The style is drop-down list box
        return UITypeEditorEditStyle.DropDown;

//Some data object
public class Car 
    //Some fields
    private double price;
    private double maxSpeed;
    private Color color;

    //Declaration of the CustomEditor. This declaration is also used by the System.Windows.Forms.PropertyGrid, so your object 
    //can be edited in the same way in various grids. 
    [Editor(typeof(CustomEditor), typeof(UITypeEditor))]
    public double MaxSpeed
        get { return maxSpeed; }
        set { maxSpeed = value; }

    //The declaration of the Editor can be done in the column
    public double Price
        get { return price; }
        set { price = value; }

    //Default color editor is used (System.Drawing.Design.ColorEditor). 
    //This editor is returned by the TypeDescriptor.GetEditor(typeof (Color), typeof (UITypeEditor)) call; 
    public Color Color
        get { return color; }
        set { color = value; }

//Initialize the grid
public void AddDataObjectToGrid(Grid grid)
    //Configure the headers
    grid.Headers.Add(new Header());
    grid.Headers[0].Add(new Column("MaxSpeed"));
    grid.Headers[0].Add(new Column("Price"));
    grid.Headers[0].Add(new Column("Color"));

    grid.Headers[0]["MaxSpeed"].Editable = true;
    grid.Headers[0]["Price"].Editable = true;
    //Declare the editor only for the current grid
    grid.Headers[0]["Price"].Editor = new CustomEditor();
    grid.Headers[0]["Color"].Editable = true;

    //Add a data object
    grid.Rows.Add(new Car());

    //Edit the cell programmatically


Inheritance Hierarchy


Thread Safety

The class is not thread safe.

See Also