Re: Change the name of an component at runtime
- From: "Clinton R. Johnson" <spam@xxxxxxxxxxxxx>
- Date: 10 May 2006 06:48:18 -0700
Paul Thanner wrote:
some time ago I saw a unit which could change the name of a
companent at runtime... and now I can't find it
does anyone know its whereabouts
All this does is change the name property of the component. As such,
just setting the .Name property should do what you need. Bindings at
compile time are done by reference and would not change. Even the
bindings in the DFM (and property inspector) are actually by reference,
as they only use the name to track down the object as the form is
loaded, and after that it is all done by pointer.
Changing the name of a component at runtime could potentially have a
negative effect on other forms you might load after that if they refer
to the component you are renamimg (as they load, they do use the name
property to lookup pointers and expect to find the named component. I
haven't tested, but they might not even be type safe at that point
leading to some seriously bad ju-ju otherwise known as rogue code,
invadlid points, and their friends general protection faults)
WARNING : Changing to a name that is already in use or is invalid as a
Delphi identifier will generate exceptions.
I guess basically we are saying that there aren't a lot of good reasons
to actually rename a component at run time and it can have a serious
downside.
Why do you need to rename a component at runtime anyways? I can't say
I have ever needed to actually do it in over 10 years.
.
- Follow-Ups:
- Re: Change the name of an component at runtime
- From: TJC Support
- Re: Change the name of an component at runtime
- References:
- Change the name of an component at runtime
- From: Paul Thanner
- Change the name of an component at runtime
- Prev by Date: Special DBGrid
- Next by Date: Re: Special DBGrid
- Previous by thread: Re: Change the name of an component at runtime
- Next by thread: Re: Change the name of an component at runtime
- Index(es):
Relevant Pages
|