Hai LOMBI,
schaue Dir mal diesen Code an. Das sollte dir helfen dein Problem zu lösen
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var
ndx : Integer;
begin
for ndx := 0 To Pred (ControlCount) do
begin
if ((Controls[ndx]) IS TDBEdit) then // Alle TEdits berücksichtigen
begin
(Controls[ndx] As TDBEdit).OnEnter := EditEnter; // OnEnter-Methode zuweisen
(Controls[ndx] As TDBEdit).OnExit := EditExit; // OnExit-Methode zuweisen.
(Controls[ndx] As TDBEdit).OnChange := EditChange; // OnChange-Methode zuweisen.
end;
end;
end;
procedure TForm1.EditEnter(Sender: TObject); // OnEnter
begin
(Sender As TDBEdit).Color := clAqua; // Sender auswerten
end;
procedure TForm1.EditExit(Sender: TObject); // OnExit;
begin
(Sender As TDBEdit).Color := clWhite;
end;
procedure TForm1.EditChange(Sender: TObject); // OnChange
begin
(Sender As TDBEdit).Color := clYellow;
end;
procedure TForm1.EditColorReset; // Alle DBEDit auf weiss ausser dem aktiven
var
ndx : Integer;
begin
for ndx := 0 To Pred (ControlCount) do
begin
if ((Controls[ndx]) IS TDBEdit) then
begin
(Controls[ndx] As TDBEdit).Color := clWhite;
end;
end;
if (ActiveControl IS TDBEdit) then
begin
(ActiveControl AS TDBEDit).Color := clAqua;
end;
end;
procedure TForm1.Query1BeforeScroll(DataSet: TDataSet);
var
ndx : Integer;
begin
for ndx := 0 To Pred (ControlCount) do
begin
if ((Controls[ndx]) IS TDBEdit) then
begin
(Controls[ndx] As TDBEdit).OnChange := nil;
end;
end;
end;
procedure TForm1.Query1AfterScroll(DataSet: TDataSet);
var
ndx : Integer;
begin
for ndx := 0 To Pred (ControlCount) do
begin
if ((Controls[ndx]) IS TDBEdit) then
begin
(Controls[ndx] As TDBEdit).OnChange := EditChange;
end;
end;
end;
procedure TForm1.Query1AfterPost(DataSet: TDataSet);
begin
EditColorReset;
end;
procedure TForm1.Query1AfterCancel(DataSet: TDataSet);
begin
EditColorReset;
end;
Stephan B.
"Lasst den Gänsen ihre Füßchen"