Re: Change the name of an component at runtime



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.
.



Relevant Pages

  • Re: XControls: Dynamic loading & polymorphism
    ... samefoo.vi loads the wrapper VI of your choice into a subpanel. ... wrapper VI contains the XControl and outputs a reference to it. ... load foo2, ...
    (comp.lang.labview)
  • Re: Strange Problems with VBA
    ... This causes a conflict when you try to rename a form to the ... "Forms" collection or run the test form and save a reference to the object ... it you can find the reference and destroy the form and set it's reference to ... "David C. Holley" wrote in message ...
    (microsoft.public.office.developer.vba)
  • Accessing Members of Dynamically Loaded Assemblies
    ... I plan to load an assembly during application startup, ... runtime reference to that dynamically loaded assembly? ... the current app domain before going to the assembly manifest to try to load ... then goes through the normal probing ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Thread mysteriously terminates.
    ... into the "aggregator" class is throttled to about 1/4 of the load i ... happen on multi-proc HT emabled machines, ... but only has one reference. ... there for some reason. ...
    (microsoft.public.dotnet.framework.performance)
  • Re: No Current Record
    ... If you load the northwind or any other database, ... I did add a reference to his app but that ...
    (comp.databases.ms-access)