List Info

Thread: Dynamically codified a TNotifyEvent




Dynamically codified a TNotifyEvent
user name
2006-04-02 18:12:33
Hello Everybody,

I am trying to dynamically attach a routine to a group of controls.
Let's say I have a multitude of Edit boxes on a form and I want
to "SelectAll" the content of each edit box "OnEnter", if the edit
box is not empty. I tried this:

...
for i:=0 to pred(ComponentCount) do
if Components[i] is TEdit then
(Components[i] as TEdit).OnEnter:=SelectAll((Components[i] as
TEdit));
...

procedure Tform1.SelectAll(aField: TEdit);
begin
 ;  if aField.Text <> '' then
&nbsp;  aField.SelectAll;
end;

This approach generates an error when I compile the codes. I remain
convinced that there is an easier way other than coding the OnEnter
event of each individual Edit box. Can somebody, please, help? TIA.


Emmanuel




[1]

about | contact  Other archives ( Real Estate discussion Medical topics )