Category / Section
What are the possible ways to enable edit in WinForms GridControl?
1 min read
Steps for enable the edit mode
There are two possible ways to enable edit mode in Grid Control. One is activating the current cell and the other is moving the current cell to desired location and enter edit mode.
To set the cursor in the current cell, use the third argument GridSetCurrentCellOptions in the Activate method.
C#
///Method1 //activate the current cell and enters to the edit mode. this.grid.CurrentCell.Activate(e.RowIndex, e.ColIndex); //To set the cursor in the current cell, use the third argument GridSetCurrentCellOptions in the Activate method this.grid.CurrentCell.Activate(e.RowIndex, e.ColIndex, GridSetCurrentCellOptions.SetFocus); ///Method2 // by moving the current cell to the desired location and call theCurrentCell.BeginEdit method to enter the edit mode. this.grid.CurrentCell.MoveTo(3, 5); this.grid.CurrentCell.BeginEdit(true);
VB
'''Method1 'activate the current cell and enters to the edit mode. Me.grid.CurrentCell.Activate(e.RowIndex, e.ColIndex) 'To set the cursor in the current cell, use the third argument GridSetCurrentCellOptions in the Activate method Me.grid.CurrentCell.Activate(e.RowIndex, e.ColIndex, GridSetCurrentCellOptions.SetFocus) '''Method2 ' by moving the current cell to the desired location and call theCurrentCell.BeginEdit method to enter the edit mode. Me.grid.CurrentCell.MoveTo(3, 5) Me.grid.CurrentCell.BeginEdit(True)
Screenshot: