Re:Delphi 4 - DBCtrlGrid and DBEdit: OnEnter & OnExit
Quote
Michael Glatz wrote:
> Very interesting. I just placed 4 DBEdit components in a Control grid and
> had no problems at all getting the OnEnter and OnExit events to fire.
> --
> Michael Glatz
> mgl...@caiso.com
> J. Schmidt wrote in message <782l4h$bt...@forums.borland.com>...
> >Hello!
> >Who can help me? I have following problem using TDBCtrlGrid:
> >I place more TDBEdit components on it. Then I declare the OnEnter and
> OnExit
> >events for the TDBEdit's. But nothing happens. Controlling by the de{*word*81}
> I
> >saw that immediately after the occurrence of the OnEnter event occurs the
> >OnExit event too. The same thing happens on a simple TPanel, but not if the
> >TDBEdits are inserted into the TForm itself.
> >I tried to create own TDBEdit components, but there is the problem with the
> >private methods needed for the repaint in selected state.
> >Has someone an idea how to resolve the OnEnter/OnExit story?
> >Thanks to everyone who tries to help me.
> >John
> >j...@spectraweb.ch
Try following:
Set all TDBEdits like this:
TDBEdit.ParentColor = True
TDBEdit.BorderStyle = bsNone
Add to all TDBEdits the same OnEnter and OnExit:
OnEnter:
--------
begin
if Sender is TDBEdit then with Sender as TDBEdit do
begin
Color := clWindow;
BorderStyle := bsSingle; // (!)
end;
end;
OnExit:
-------
begin
if Sender is TDBEdit then with Sender as TDBEdit do
begin
ParentColor := True;
BorderStyle := bsNone; // (!)
end;
end;
Thit should cause the DBEdits to behave like flat fields, getting an
active appearence only in the selected state.
It seems that the change of the BorderStyle property causes another
OnExit event, which has to be eliminated anyhow.
John