When I put a checkbox on a frame at design time and change its name at runtime , it seems to become nil when referenced by its original name.
This is working by design. It behaves the same way in Lazarus as it does in Delphi.
At design-time, dropping a component onto the Designer will create a
published field in the
Owner and name that field the same as the component's
Name. If you then change the component's
Name at design-time, the
published field is renamed to match.
Then at runtime, when the DFM/LFM is streamed in, the component gets created in memory and its
Name is assigned its design-time value, at which time the RTL updates the corresponding
published field in the
Owner to point at the component.
If you later change the component's
Name at run-time, the original
published field can't be renamed anymore (it is read-only in the
Owner's RTTI), but it can and does get updated to
nil. If there is another
published field available in the same
Owner that already has the new name in the
Owner's RTTI, it will be updated to point at the component.
If I created a checkbox at runtime and rename it , it can still be referenced by its original name.
That is only true if the field that points at the component is not declared as
published, thus changing the component's
Name will not update the field.
Is this intentiona to have different behavior for controls created at runtime ?
Yes.