Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread TControl Selection in Property Editor
Mon, Dec 19 2016 4:44 AMPermanent Link

Michael Dreher

The TSizer control has a published "control" property of type TControl, and in the object inspector I can select from a combobox any control of the active form. Now I want to use this control selection in my component:

type
 TMyClass = class(TComponent)
 private
   FSourceControl  : TControl;
 public
   // ...
published
   property SourceControl : TControl read FSourceControl write FSourceControl;
 end;

But then after a library/rebuild in the object inspector I see something like this:

 [+] SourceControl   |   (TControl)

The [+] on the left is some sort of tree expansion button and on the right there is no combobox but a readonly text "(TControl)". Is there somthing wrong in my code. What do I have to do to get the combobox here?

Michael Dreher
Mon, Dec 19 2016 3:54 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Michael,

<< But then after a library/rebuild in the object inspector I see something like this:

 [+] SourceControl   |   (TControl)

The [+] on the left is some sort of tree expansion button and on the right there is no combobox but a readonly text "(TControl)". Is there somthing wrong in my code. What do I have to do to get the combobox here? >>

Yes, this is one of the unmentioned finer points of component development in EWB.  What you want is the "reference" keyword, which tells the IDE that you're using a reference, as opposed to an embedded control that requires its own component editor:

type
 TMyClass = class(TComponent)
 private
   FSourceControl  : TControl;
 public
   // ...
published
   property SourceControl : TControl read FSourceControl write FSourceControl reference;
 end;

You can see this "in action" in the WebCtrls unit for the TBindableControl and TDataSet references.

Tim Young
Elevate Software
www.elevatesoft.com
Image