Zsolt
2004-01-22 10:06:09 UTC
Hi guys!
I have 2 own components:
MyLabel = class(TLabel)
private
protected
public
procedure DoSomething(something:string);
published
end;
MyEdit = class(TEdit)
private
protected
public
procedure DoSomething(something:string);
published
end;
Both of them has a DoSomething procedure.
I put some MyEdit and MyLabel components to a new form and in the form.create i go through the components on the form (i know that only MyLabel and MyEdit type components are on the form) with the following code:
for k:=0 to ControlCount-1 do
Controls[k].DoSomething(something);
And this is where the problems starts. Controls[k] type is TControl, so the compiler thinks it doesnt have DoSomething procedure. I know that Controls[k]'s type can be only MyLabel and MyEdit (which do have DoSomething procedure) and maybe i should use some kind of typecasting here but i dont know how/what.
Can u help me what should i do/how should i do exactly?
Thanx in advance,
Zsolt
p.s: please post the answer to my email-addy, also, thanx
I have 2 own components:
MyLabel = class(TLabel)
private
protected
public
procedure DoSomething(something:string);
published
end;
MyEdit = class(TEdit)
private
protected
public
procedure DoSomething(something:string);
published
end;
Both of them has a DoSomething procedure.
I put some MyEdit and MyLabel components to a new form and in the form.create i go through the components on the form (i know that only MyLabel and MyEdit type components are on the form) with the following code:
for k:=0 to ControlCount-1 do
Controls[k].DoSomething(something);
And this is where the problems starts. Controls[k] type is TControl, so the compiler thinks it doesnt have DoSomething procedure. I know that Controls[k]'s type can be only MyLabel and MyEdit (which do have DoSomething procedure) and maybe i should use some kind of typecasting here but i dont know how/what.
Can u help me what should i do/how should i do exactly?
Thanx in advance,
Zsolt
p.s: please post the answer to my email-addy, also, thanx