default value in Delphi component

Posted on 2013-06-12
Last Modified: 2013-06-12

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)
      FSaveOrder : boolean;
      property SaveOrder: boolean read FSaveOrder write FSaveOrder default true;

Open in new window

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

Accepted Solution

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

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

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

Open in new window

... and set FSaveOrder to True. Remove

Author Closing Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
splitOdd10 challenge 5 80
Eclipse Neon start with Admin account only 6 94
Currency Conversion? 1 73
program a usb light to turn on when needed 6 49
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

920 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

13 Experts available now in Live!

Get 1:1 Help Now