Board index » delphi » Set The Color or A tdedit comp when the focus is set on it

Set The Color or A tdedit comp when the focus is set on it

I want to set the color of a tdedit field when it receieves focus
and then change it back to the orginal color when it loses focus.

Is this tough or am I being dumb?

Tanx
RossH

 

Re:Set The Color or A tdedit comp when the focus is set on it


Quote
ne...@compusmart.ab.ca (Ross Hodgson) wrote:
>I want to set the color of a tdedit field when it receieves focus
>and then change it back to the orginal color when it loses focus.

I suppose you could change the font color 'OnEnter' and change it back
'OnExit'
--
Chuck Eckenroed
Sun Valley Software, Inc.

Re:Set The Color or A tdedit comp when the focus is set on it


Quote
ne...@compusmart.ab.ca (Ross Hodgson) wrote:
>I want to set the color of a tdedit field when it receieves focus
>and then change it back to the orginal color when it loses focus.
>Is this tough or am I being dumb?
>Tanx
>RossH

You choose the colors, but try something like
the following (in the object insepctor,
double click on the Enter and Exit (refers to
getting and losing focus) events of your edit
component to get the empty routines automagically):

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  Edit1.Color:= clYellow;
end;

procedure TForm1.Edit1Exit(Sender: TObject);
begin
  Edit1.Color:= clWindow;
end;

If you want to do the same thing for a bunch
of Edits, use (Sender as TEdit) in place of
the specific edit box name, e.g.,

procedure TForm1.Edit1Enter(Sender: TObject);
begin
  (Sender as TEdit).Color:= clYellow;
end;

Then after the first edit generic routines
are in, don't double click on the events,
for your subsequent edit boxes. Just
click once, then click on the down arrow
at the right, and select the routine you want
from the list of existing ones. Sender
refers to the particular Edit that generated
the event, so your routine is general for
TEdit controls (in this example).

HTH

Regards,
Bengt Richter
Please don't take offense at the detail. It may
be useful to someone else, (hopefully).

Re:Set The Color or A tdedit comp when the focus is set on it


Quote
b...@accessone.com (Bengt Richter) wrote:
>ne...@compusmart.ab.ca (Ross Hodgson) wrote:
>>I want to set the color of a tdedit field when it receieves focus
>>and then change it back to the orginal color when it loses focus.
>>Is this tough or am I being dumb?
>>Tanx
>>RossH

I feel a little dumb. I didn't see the 'd' in
your 'tdedit' (but then I didn't see the 'b' either ;-)
And I only dealt with the background. See Keith Power's
post for what you probably wanted.

Sorry,
Bengt Richter

Other Threads