Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

default value in Delphi component

Posted on 2013-06-12
2
Medium Priority
?
558 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 28

Accepted Solution

by:
Sinisa Vuk earned 2000 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Suggested Courses

609 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