Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to avoid saving a property to dfm file?

Status
Not open for further replies.

rcloutie

Programmer
May 26, 2005
164
CA
Hi there,

I've built a grid control inherited from TStringGrid for which I do not want to save a specific property (since it is always determined at run-time). The property in question is RowHeights (array property inherited from TCustomGrid).

Even if I redeclared the property within my control as
Code:
property RowHeights stored False;

In the dfm, values still stored as
Code:
object cgrCalc: TMyGrid
  RowHeights = (
    17
    17
    17
    17
    17)
end

After modification done at design-time in some forms implementing the control (via a frame), there's a run-time error raised saying there's an Invalid Property Value and prevents from opening the form. After editing and deleting the RowHeights property right in the dfm, the next exe compilation is ok. But I would like to avoid editing the dfm to delete RowHeights after any minor changes in the code.

The migration from D2010 -> DXE7 is harder than what I thought at first place... :-/
 
With about anything, including Delphi, I've always taken any auto-generated files to be uneditable, unless I can copy it out (and I have to sometimes for type libraries as they get translated improperly a lot of times). When I want certain properties assured in my Delphi projects, I specifically set them in the Create event for the form the control is on and forget the property sheets. Of course, if that's an issue, you can always dynamically create and place the control onto the form.

As for the question of the properties, when you inherit from another control, you're pretty much stuck with what you get from the other control. The only other thing you may try different is to register your control into the IDE (i.e. so you can click it in the IDE menu and put it onto your form), as you have to do that before the IDE itself knows what to do about the control. Since your control descends from a parent control that will be registered within the IDE, it probably is taking on the behaviors the IDE knows about from that control.

Not sure that'll help out, but hope it does.

 
Thanks for reply,

I know, an autogenerated file must be handle with care :-/ In fact, I've never had to play directly in the dfm (I swear!), it's the reason behind this post: I don't want to do it on a regular basis. The problem is there only since migration of our projects from D2010 to XE7. The worst point is that compilation always succeeded while run-time error Invalid Property Value is raised before displaying the form.

I read that properties are written to the dfm only when default values are changed... but this is not my case. Anyway, I will continue to search for a solution and I will post results here.

Thanks again for your time,

RC




 
OK finally I get rid of the problem...

The run-time error Invalid Property Value is no more raised after I edited the form's dfm AND all frames dfm taking place in the form. The task consists of deleting all occurences of DefaultRowHeight, RowCount and RowHeights. In some frame's dfm, I saw RowCount=6 while RowHeights stops at 5...???... I think this was causing the error since I can now make minor changes to the form and all is ok on run-time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top