Re: How to dynamically rename a component in the object inspector ?
- From: Dirk Claessens <will.bounce@invalid>
- Date: Fri, 23 Dec 2005 15:44:00 GMT
Verily, on Fri 23 Dec 2005 11:58:05a, David AFONSO wrote in
comp.lang.pascal.delphi.misc
[news:43abd75e$0$6655$8fcfb975@xxxxxxxxxxxxxxx]:
> For Instance : I link a DBEdit to a DB Field named "Folder" and I
> want the DBEdit's name to change from "DBEdit1" to "Folder"
> automatically.
>
To give you an idea of the practical problems you'll encounter by
doing this kind of thing, try this:
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Name := 'NewName';
end;
Now click the button a second time...
I'm unsure of what you're trying to do, but what you _can_ do with
Delphi is calling an object's method by name, i.e. doing
MyComponent.Execute('DoThis'), MyComponent.Execute('DoThat')
{$M+} // do not forget to switch on RTTI
//-----------------------------------------------
procedure TMyClass.Execute( MethodName: string );
type
Call = procedure of object;
var
Method : TMethod;
begin
Method.Data := Self;
Method.Code := Self.MethodAddress( MethodName );
if Method.Code <> nil then
Call( MethodName )
else
raise SomeException.Create( 'Method ' + Self.ClassName + '.' +
MethodName + ' does not exist' );
end;
{ other method declarations }
{$M-}
Note: method names are _case_sensitive_
--
Dirk.
No trees were killed in the creation of this message;
however, many electrons were terribly inconvenienced.
http://users.pandora.be/dirk.claessens2
.
- References:
- How to dynamically rename a component in the object inspector ?
- From: David AFONSO
- How to dynamically rename a component in the object inspector ?
- Prev by Date: Re: fast drawing in delphi
- Next by Date: Re: fast drawing in delphi
- Previous by thread: How to dynamically rename a component in the object inspector ?
- Next by thread: Re: How to dynamically rename a component in the object inspector ?
- Index(es):