1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
| unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Grids, ValEdit;
type TForm1 = class(TForm) ValueListEditor1: TValueListEditor; procedure ValueListEditor1GetEditText(Sender: TObject; ACol, ARow: Integer; var Value: String); procedure ValueListEditor1Validate(Sender: TObject; ACol, ARow: Integer; const KeyName, KeyValue: String); procedure ValueListEditor1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); private public CurrentValue: String; end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.ValueListEditor1GetEditText(Sender: TObject; ACol, ARow: Integer; var Value: String); begin CurrentValue := Value; end;
procedure TForm1.ValueListEditor1Validate(Sender: TObject; ACol, ARow: Integer; const KeyName, KeyValue: String); var X: Integer; IsNumeric: Boolean; begin IsNumeric:=False;
for x:=1 to Length(KeyValue) do begin if KeyValue[x] in ['0'..'9'] then begin IsNumeric:=True; end else begin IsNumeric:=False; Break; end; end;
if IsNumeric = False then begin ValueListEditor1.Cells[ACol, ARow] := CurrentValue; end else begin CurrentValue:=KeyValue; end; end;
procedure TForm1.ValueListEditor1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_RETURN then begin ValueListEditor1.OnValidate(nil, ValueListEditor1.Col, ValueListEditor1.Row, ValueListEditor1.Keys[ValueListEditor1.Row], ValueListEditor1.Values[ValueListEditor1.Keys[ValueListEditor1.Row]]); end; end;
end. |