You can use Grid.CellEditor callback to define an editor that will be used by the grid to edit cells. You can also use this callback to prevent editing of some cells. An example of using this callback is provided below.

C# Copy imageCopy
public DynamicallyCreatedEditorControl()
{
    InitializeComponent();

    //...
    grid.CellEditor += OnCellEditor;
}

static void OnCellEditor(object sender, GridCellEditableEventArgs e)
{
    //Dropdown menu with string values
    if (e.Cell.Column.Id == "Column 1")
    {
        List<string> collection = new List<string>();
        foreach (Row child in e.Cell.Row.Parent.Children)
        {
            if (child.Dock == RowDockStyle.None)
            {
                string value = (string)child[e.Cell.Column.Id].Value;
                if (!collection.Contains(value))
                {
                    collection.Add(value);
                }
            }
        }

        //Create a custom editor
        e.Editor = new EnumerableEditor(collection, true);
    }

    //Trackbar menu
    else if (e.Cell.Column.Id == "Column 2")
    {
        e.Editor = new TrackBarEditor(0, 1000);
    }
}

Back to .Net Grid HowTo topics