Contents - Index - Previous - Next


OnKeyPressEx event



Applies to
TProfGrid component

Declaration
property OnKeyPressEx: TProfGridKeyPressExEvent;

Description

Occurs right after the OnKeyPress event if the grid is in edit mode.

The event provides more flexibility for user's input auto-correction. Use OnKeyPressEx rather than OnKeyPress if you need more control over the user's typing.

Note:  The event works only with the built-in inplace editor.


Example

The following event handler ensures that only a real number can be input to a cell.

procedure TForm1.ProfGrid1KeyPressEx(Sender: TProfGrid; var Key: Char;
  ACol, ARow: Integer; var EditText: WideString; var Position: Integer);
var
  S: WideString;
  D: Double;
begin
  if Key <> #8 then
  begin
    S := EditText;
    Insert(Key, S, Position + 1);
    if not TryStrToFloat(S, D) and (S <> '-') then
      Key := #0
  end
end;