Solved

default value in Delphi component

Posted on 2013-06-12
2
504 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 25

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A short article about a problem I had getting the GPS LocationListener working.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now