Contents - Index - Previous - Next


OnCellChanged event



Applies to
TProfGrid component

Declaration
property OnCellChanged: TProfGridCellChangedEvent;

Description

Occurs when the user has made some changes and attempts to leave the edited cell.

Write an OnCellChanged event handler for user input validation or auto correction. The NewText parameter contains the text typed by the user. For auto correction, the edited string passed in the NewText parameter may be changed. Then the corrected text will be entered in the cell rather than the text typed by the user.

You may also set the AllowExit parameter to False if input is not accepted, thus forcing the user to continue editing.


Example

The following event handler prevents the grid from resolving data types of the strings typed by the user in column 1 of the grid. Adding a leading apostrophe (') to the string typed by the user forces the grid to consider any entered data as a string (and not as a number, a date, etc.).

procedure TForm1.ProfGrid1CellChanged(Sender: TProfGrid; ACol,
  ARow: Integer; const OldText: WideString; var NewText: WideString;
  var AllowExit: Boolean);
begin
  if ACol = 1 then
    NewText := '''' + NewText
end;