FlexGrid for WinForms
Edit Mode

You can determine whether the grid is in edit mode by reading the value of the Editor property. If this property returns null, the grid is not in edit mode. Otherwise, the grid is in edit mode and the property returns a reference to the control that is being used to edit the cell (the control may be a TextBox, a ComboBox, or other type of control).

You can put the grid in edit mode programmatically using the StartEditing method, and finish editing using the FinishEditing method.

You can also set PreserveEditMode to retain edit mode of cells in a grid on navigation, using arrow or tab keys.

You can control the editing process further by handling the editing events fired by the grid. In the process of editing a cell, the grid fires the following sequence of events:

Event Description
BeforeEdit This event fires whenever an editable cell is selected. It allows you to prevent the cell from being edited by setting the event's Cancel parameter to True. You can also modify the ComboList property so the appropriate drop-down button gets painted in the cell. Note that the user might not actually start editing after this, he could simply move the selection to a different cell or control.
StartEdit This event is similar to BeforeEdit, except the user has actually typed a key or clicked the dropdown button in the cell and really is about to start editing. You can still cancel the editing at this point. Note that the Editor property is still null at this point, because the control hasn't yet determined the type of editor that should be used. You can assign custom editors to the Editor property at this point.
SetupEditor This event fires after the editor control has been created and configured to edit the cell, but before it is displayed. You can change the editor properties at this point (for example, set the maximum length or password character to be used in a TextBox editor). You can also attach your own event handlers to the editor.
ValidateEdit This event fires when the user is done editing, before the editor value gets copied back into the grid. You can examine the original value by retrieving it from the grid (the event provides the coordinates of the cell). You can examine the new value about to be assigned to the grid through the Editor properties (for example, Editor.Text). If the new value is not valid for the cell, set the Cancel parameter to True and the grid will remain in edit mode. If instead of keeping the cell in edit mode you would rather restore the original value and leave edit mode, set Cancel to True and then call the FinishEditing method.
AfterEdit This event fires after the new value has been applied to the cell and the editor has been deactivated. You can use this event to update anything that depends on the cell value (for example, subtotals or sorting).
See Also

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum |  Documentation Feedback