Skip to main content

Cell Editing

Comments

1 comment

  • Dapfor Team

    Hi,

    You can use a custom editor:

     

    internal class MyEditor : UITypeEditorEx
    {
        public override StopEditReason EditCell(IGridEditorService service, Cell cell, StartEditReason reason)
        {
            using (var control = new TextBox())
            {
                control.BackColor = Color.BurlyWood;

                //control
                control.KeyDown += (sender, args) =>
                {
                    //Key is pressed here. Set value

                    cell.Text = "200";
    //or
    cell.Value = 200;
                   
    service.CloseCellControl(StopEditReason.UserStop);
                };

                return service.CellEditControl(control, cell.VirtualBounds, reason);
            }
        }
    }

    //Use attributes to set the editor
    public class Order
    {
        [Editor(typeof(MyEditor), typeof(UITypeEditor))]
        public decimal Amount { get; set; }
    }

    //or set it per column:
    grid.Headers[0]["MyColumn"].Editor = new MyEditor();

    //or you can also set this editor dynamically when the user clicks on the cell
    grid.CellEditor += delegate(object sender, GridCellEditableEventArgs e)
    {
        e.Editable = true;
        e.Editor = new MyEditor();
    };

     

    Best regards,

    Dapfor

    0

Please sign in to leave a comment.

Powered by Zendesk