Autor Beitrag
Seven
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 16



BeitragVerfasst: Di 22.07.03 12:49 
Hallo leute,

ich möchte bei bestimmten Cellen in meinem VLE, bei denen Picklisten vorhanden sind, keine händige eingabe zu lassen wie kann man sowas anstellen ????


Ansonsten, wenn es dafür nix ad hoc gibt, müsste ich wissen wie ich eben eine händige eingabe überprüfen kann und wenn, eine MSG BOx ausgeben kann und dan den alten wert wieder reinschreibe..

jemand ne Idee ?
Danke Grüsse
specialwork
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 52

Windows XP Professional; Windows Server 2003
Delphi 7 Prof, Delphi 8.Net
BeitragVerfasst: Di 22.07.03 22:21 
Titel: Im TValueListEditor auf Numerische Werte überprüfen
Hallo Seven,

Folgende Unit zeigt, wie man manuell eingegebene Strings validieren und ggfs. rückgängig machen kann.

Vieleicht kannst Du ja etwas damit anfangen.

Gruß, Tom

Source:

ausblenden volle Höhe Delphi-Quelltext
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
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    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.