Solved

default value in Delphi component

Posted on 2013-06-12
2
513 Views
Last Modified: 2013-06-12
Hi

I have an own component where I add a property SaveOrder with a default value. If I add the component on design-time the SaveOrder is false instead of true:
  tTest = class(TDbGrid)
    private
      FSaveOrder : boolean;
    published
      property SaveOrder: boolean read FSaveOrder write FSaveOrder default true;
  end;

Open in new window


See my simple sample. What's wrong?
Thanks, Peter
0
Comment
Question by:formi
2 Comments
 
LVL 26

Accepted Solution

by:
Sinisa Vuk earned 500 total points
ID: 39240531
Override constructor Create:

...
public
    { Public declarations }
    constructor Create(AOwner : TComponent); override;
....

constructor tTest.Create(AOwner: TComponent);
begin
  inherited;
  FSaveOrder := True;
end;

Open in new window


... and set FSaveOrder to True. Remove
default
directive.
http://docwiki.embarcadero.com/RADStudio/XE4/en/Properties
0
 

Author Closing Comment

by:formi
ID: 39240566
that works - but I don't understand what for the default specifier is ...
Thanks for your help!
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question