Autor Beitrag
dirkil2
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130



BeitragVerfasst: Do 17.08.06 08:04 
Ich möchte in einem Grid nur die Eingabe von positiven Float-Zahlen gestatten. Folgende Zahlen sind z.B. gültiger Input:
3,2
3
12132,3843874387483

Eingaben wie 3874,3948E+02 sollen abgelehnt werden.

Die eigentliche Validierung, ob die Zahl gültig ist oder nicht, habe ich schon geschrieben. Mir ist nicht klar, an welchen Event ich die Validierung hängen soll. Die Validierung sollte erst beim Verlassen der Zelle stattfinden. Wenn die Validierung fehlschlägt, soll der Cursor weiterhin in der Zelle mit dem falschen Input bleiben.


Wer kann mir weiterhelfen?
oldmax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 380


D3 Prof, D4 Prof
BeitragVerfasst: Do 17.08.06 08:17 
Titel: Valiedierung von Zahlen
Hi
Also, meine Delphi-Hilfe bietet mir das Ereingnis OnSeteditText an. Wenn ich dich richtig verstanden habe, ist es das, was du willst. Beim Verlassen des Feldes die Gültigkeit prüfen um im Fehlerfall wieder in das Feld zurückkehren zu können.
Gruß oldmax

_________________
Zier dich nich so, ich krieg dich schon....
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Do 17.08.06 08:59 
Hatte ma ein ähnliches Problem. Vielleicht hilft dir das hier ja weiter :)
dirkil2 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 130



BeitragVerfasst: Do 17.08.06 09:21 
Wenn ich beispielsweise eine '5' in eine Zelle eingeben und ein Breakpoint in GridSetEditText setze, dann enthält Value den Wert '' und nicht die eingegebene '5'. Wie soll ich denn da eine Prüfung durchführen?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TPDForecastFrm.GridSetEditText(Sender: TObject; ACol,
  ARow: Integer; const Value: String);
begin
  if not IsNumeric( Value ) then
    begin
      MessageDlg(Value+' ist kein gültiger numerischer Wert.', mtError, [mbOK], 0);
      Grid.Cells[ACol,ARow] := '';
    end;
end;
Miri
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 657


Delphi 3 Prof., Delphi 2005 PE
BeitragVerfasst: Do 17.08.06 10:08 
Schau dir doch mal den Link an... da steht schon, dass du mit SetEditText nicht weiterkommst... und auch, was du stattdessen nutzen solltest ;-)