Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

delphi - published property not shown in Object Inspector

My environment: RadStudio XE4 on Windows 7 Pro (32bit).

Difference between property and function or procedures

In the above Q and A, there is a reply saying "More concretely, if you use the Delphi IDE to program, you will see that the published property (-y+ies) will show up in the Object Inspector".

I tried this.

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
  private
    FSampleProp1: Integer;
    function GetSampleProp1(): Integer;
    procedure SetSampleProp1(val: Integer);
    { Private declaration }
  published
    { Private declaration }
    property SampleProp1: Integer read GetSampleProp1 write SetSampleProp1;
  end;

I expected that I would have "SampleProp1" in the "property" tab of the Object Inspector. But I do not have that one.

Instead, I had the "SampleProp1" in the [Delphi Class Exploroer]" windows.

Is it incorrect that I would have the published property in the Object Inspector?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The Object Inspector shows only properties that are registered with the IDE in a design time package. You have not done that.

So you could include your form in a design time package and register it with a call to RegisterCustomModule. However this could be quite inconvenient if your form is under active development in your application. You might find yourself repeatedly getting out of sync between the design time package and the application.

Another way to apply form wide behaviour changes is to create a non-visual component that you can drop on to your form. The advantage of this approach is that you can change the form to your heart's content and not get out of sync with your design time components.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...