Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Properties not assigned in Create



Permlink Replies: 5 - Last Post: Nov 15, 2017 9:09 AM Last Post By: Robert Yost
Robert Yost

Posts: 12
Registered: 5/2/08
Properties not assigned in Create
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2017 8:47 AM
I am creating a simple control that adds on to an existing control.
I am using UniGUI, but I think in this regard it should be the same as a TEdit control.

I want to add a boolean that if checked makes a change in the Create constructor event.

I added a boolean property to the published section.

It shows up in design time, and I can check it.

But no matter what I check in design time when I check it in the constructor it is false (The default value)

Is there a different event I should use?

Thanks,
Rob
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Properties not assigned in Create
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2017 9:06 AM   in response to: Robert Yost in response to: Robert Yost
Robert Yost wrote:

I am creating a simple control that adds on to an existing control.
I am using UniGUI, but I think in this regard it should be the same
as a TEdit control.

I want to add a boolean that if checked makes a change in the Create
constructor event.

I added a boolean property to the published section.

It shows up in design time, and I can check it.

But no matter what I check in design time when I check it in the
constructor it is false (The default value)

Is there a different event I should use?

You cannot use a property in the constructor in that time the object is
just created and it's empty. When the component is saved to a dfm
after it's properties are read the loaded virtual method is called.
There you can read the properties.

Robert Yost

Posts: 12
Registered: 5/2/08
Re: Properties not assigned in Create
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2017 9:29 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
You cannot use a property in the constructor in that time the object is
just created and it's empty. When the component is saved to a dfm
after it's properties are read the loaded virtual method is called.
There you can read the properties.

What event should I use?

I would like to execute some code once sometime after create.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Properties not assigned in Create
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2017 10:03 AM   in response to: Robert Yost in response to: Robert Yost
Robert Yost wrote:

What event should I use?

Lajos already told you - override the virtual Loaded() method, which is
called after the component's properties have been loaded from a DFM.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Properties not assigned in Create
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2017 10:05 AM   in response to: Robert Yost in response to: Robert Yost
Robert Yost wrote:

But no matter what I check in design time when I check it in the
constructor it is false (The default value)

That is because the component's properties have not been loaded from
the DFM yet when the constructor is called.

Is there a different event I should use?

Override the virtual Loaded() method, which is called after all
properties have been loaded from a DFM. Or, give your boolean property
a setter method that does what it needs to do immediately when the
property value is assigned. Hard to say exactly what is the best
option for you without knowing what your property is actually trying to
change.

--
Remy Lebeau (TeamB)
Robert Yost

Posts: 12
Registered: 5/2/08
Re: Properties not assigned in Create
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 15, 2017 7:03 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Moving my code to the Loaded event worked perfectly. Thanks.

Is there a list of events that are standard to Window Controls

Edited by: Robert Yost on Nov 15, 2017 9:08 AM
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02