XPTable.Models.Table.EditCell C# (CSharp) Method

EditCell() public method

Starts editing the Cell at the specified CellPos
public EditCell ( XPTable.Models.CellPos cellPos ) : void
cellPos XPTable.Models.CellPos A CellPos that specifies the Cell to be edited
return void
        public void EditCell(CellPos cellPos)
        {
            // don't bother if the cell doesn't exists or the cell's
            // column is not visible or the cell is not editable
            if (!this.IsValidCell(cellPos) || !this.ColumnModel.Columns[cellPos.Column].Visible || !this.IsCellEditable(cellPos))
                return;

            // check if we're currently editing a cell
            if (this.EditingCell != CellPos.Empty)
            {
                // don't bother if we're already editing the cell.
                // if we're editing a different cell stop editing
                if (this.EditingCell == cellPos)
                    return;
                else
                    this.EditingCellEditor.StopEditing();
            }

            Cell cell = this.TableModel[cellPos];
            ICellEditor editor = this.ColumnModel.GetCellEditor(cellPos.Column);

            // make sure we have an editor and that the cell
            // and the cell's column are editable
            if (editor == null || !cell.Editable || !this.ColumnModel.Columns[cellPos.Column].Editable)
                return;

            if (this.EnsureVisible(cellPos))
                this.Refresh();

            Rectangle cellRect = this.CellRect(cellPos);

            // give anyone subscribed to the table's BeginEditing
            // event the first chance to cancel editing
            CellEditEventArgs e = new CellEditEventArgs(cell, editor, this, cellPos.Row, cellPos.Column, cellRect);

            this.OnBeginEditing(e);

            //
            if (!e.Cancel)
            {
                // get the editor ready for editing.  if PrepareForEditing
                // returns false, someone who subscribed to the editors
                // BeginEdit event has cancelled editing
                if (!editor.PrepareForEditing(cell, this, cellPos, cellRect, e.Handled))
                    return;

                // keep track of the editing cell and editor
                // and start editing
                this.editingCell = cellPos;
                this.curentCellEditor = editor;

                editor.StartEditing();
            }
        }

Same methods

Table::EditCell ( int row, int column ) : void
Table