ComponentOne True DBGrid Pro 8
BeforeColUpdate Event

 

Object Reference> True DBGrid Events> BeforeColUpdate Event

BeforeColUpdate Event

The BeforeColUpdate event occurs after editing is completed in a cell, but before data is moved from the cell to the grid's internal copy buffer.

Syntax

TDBGrid_BeforeColUpdate (ByVal ColIndex As Integer, OldValue As Variant, Cancel As Integer)

Arguments

ColIndex is an integer that identifies the column about to be updated.

OldValue is a variant containing the original data.

Cancel is an integer that may be set to True to prevent the update from occurring.

Remarks

The data specified by the OldValue argument moves from the cell to the grid's copy buffer when the user completes editing within a cell, as when tabbing to another column in the same row, pressing the Enter key, or clicking on another cell. Before the data has been moved from the cell into the grid's copy buffer, the BeforeColUpdate event is triggered. This event gives your application an opportunity to check the individual grid cells before they are committed to the grid's copy buffer.

If your event procedure sets the Cancel argument to True, the previous value is restored in the cell, the grid retains focus, and the AfterColUpdate event is not triggered. You can also change the current cell text by setting OldValue to the value you want to display (other than the previous value).

To restore OldValue in the cell and permit the user to move focus off of the cell, set Cancel to False and set the cell to OldValue as follows:

Cancel = False

TDBGrid1.Columns(ColIndex).Value = OldValue

Setting the Cancel argument to True prevents the user from moving focus away from the control until the application determines that the data can be safely moved back to the grid's copy buffer.

See Also

TDBGrid Control

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback