Board index » delphi » Sender : TObject ?

Sender : TObject ?

I am using 6 TEdit objects to enter some strings. I want to check if there
is any strings in the objects, by calling the onExit event. The problem is
that I want to use one procedure for all 6 objects, using sender in an if
statement .

if Sender is TEdit then
  ...

This doesn't seem to be working.

Any comments or help would be greatly appreciated

Doors Potgieter
d...@lantic.net

 

Re:Sender : TObject ?


Example:

procedure TForm1.Edit1Exit(Sender: TObject);
begin
  if (Sender is TEdit) and (TEdit(Sender).Text = '') then
  begin
    MessageDlg('You forgot to enter a value !', mtError, [mbOk], 0);
    TEdit(Sender).SetFocus;
  end;
end;

"Doors" <d...@lantic.net> schreef in bericht
news:98kkup$gsg$1@ctb-nnrp2.saix.net...

Quote
> I am using 6 TEdit objects to enter some strings. I want to check if there
> is any strings in the objects, by calling the onExit event. The problem is
> that I want to use one procedure for all 6 objects, using sender in an if
> statement .

> if Sender is TEdit then
>   ...

> This doesn't seem to be working.

> Any comments or help would be greatly appreciated

> Doors Potgieter
> d...@lantic.net

Re:Sender : TObject ?


procedure ...
var XEdit:TEdit;
begin
    XEdit:= Sender as TEdit;
    If Edit.Name = ?? then
      begin
      end;
end;

"Doors" <d...@lantic.net> schrieb im Newsbeitrag
news:98kkup$gsg$1@ctb-nnrp2.saix.net...

Quote
> I am using 6 TEdit objects to enter some strings. I want to check if there
> is any strings in the objects, by calling the onExit event. The problem is
> that I want to use one procedure for all 6 objects, using sender in an if
> statement .

> if Sender is TEdit then
>   ...

> This doesn't seem to be working.

> Any comments or help would be greatly appreciated

> Doors Potgieter
> d...@lantic.net

Re:Sender : TObject ?


Thank you. This is exactly what I wanted to do.

Kind regards,
Doors Potgieter

Quote
"Doors" <d...@lantic.net> wrote in message

news:98kkup$gsg$1@ctb-nnrp2.saix.net...
Quote
> I am using 6 TEdit objects to enter some strings. I want to check if there
> is any strings in the objects, by calling the onExit event. The problem is
> that I want to use one procedure for all 6 objects, using sender in an if
> statement .

> if Sender is TEdit then
>   ...

> This doesn't seem to be working.

> Any comments or help would be greatly appreciated

> Doors Potgieter
> d...@lantic.net

Other Threads