Solved

default value in Delphi component

Posted on 2013-06-12
2
523 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

A short article about a problem I had getting the GPS LocationListener working.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

733 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