Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Update my own TStringGrid



Permlink Replies: 4 - Last Post: Feb 28, 2018 8:41 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Peter Herijgers

Posts: 20
Registered: 3/16/00
Update my own TStringGrid
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 12:25 AM
Hi All,

I have created my own TStringGrid with FixedRows := 7.
Now I have updated my TStringGrid and FixedRows is now 8.
Is there a way to update all the TStringGrid components in my project automatically without creating them again?
I use these TStringGrid components a lot in my project and just removing them from a form and reinstalling them is not an option.

Any ideas?

Thanks in advance.
Peter
Peter Herijgers

Posts: 20
Registered: 3/16/00
Re: Update my own TStringGrid
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 1:31 AM   in response to: Peter Herijgers in response to: Peter Herijgers
Peter Herijgers wrote:
I have created my own TStringGrid with FixedRows := 7.

Maybe to ease the search for changed components, is it possible to search for a text like FixedRows = 7 in all the dfm files?
Roy Lambert

Posts: 40
Registered: 10/21/99
Re: Update my own TStringGrid
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 1:40 AM   in response to: Peter Herijgers in response to: Peter Herijgers
Peter

If your forms dfm files are stored in plain texty it should be possible to do a mass search & replace operation. I wrote my own a decade or two back but there are options out there. All you need is to identify the changes that need making.

Roy Lambert

Robert Triest

Posts: 687
Registered: 3/24/05
Re: Update my own TStringGrid
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 1:42 AM   in response to: Peter Herijgers in response to: Peter Herijgers
I have created my own TStringGrid with FixedRows := 7.
Do you mean "Your Own" like, you inherited a Grid from TStringGrid?
If you inherit your own and use that TStringGrid in your code, you can set the
FixedCol in the Create of the Grid. In this way you only have to change the property on one place.

https://stackoverflow.com/questions/32946263/how-to-create-custom-editor-for-tstringgrid-tstringgrid-as-parent-for-other-co

I use these TStringGrid components a lot in my project and just removing them from a form and reinstalling them is not an option.
Why you have to remove them? You just change the FixedCol property of the Grids..
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Update my own TStringGrid
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 8:41 AM   in response to: Robert Triest in response to: Robert Triest
Robert Triest wrote:

If you inherit your own and use that TStringGrid in your code, you
can set the FixedCol in the Create of the Grid. In this way you only
have to change the property on one place.

And also set your custom initial value as the new property default
value, so that the property is not saved in the DFM unless you give it
a non-default value at design-time.

type
  TMyStringGrid = class(TStringGrid)
  public
    constructor Create(AOwner: TComponent); override;
  published
    propety FixedRows default 7;
  end;
 
constructor TMyStringGrid.Create(AOwner: TComponent);
begin
  inherited;
  FixedRows := 7;
end;


If you want to change the default value later, be sure to update the
property default value to match:

type
  TMyStringGrid = class(TStringGrid)
  public
    constructor Create(AOwner: TComponent); override;
  published
    propety FixedRows default 8;
  end;
 
constructor TMyStringGrid.Create(AOwner: TComponent);
begin
  inherited;
  FixedRows := 8;
end;


If you ever only work with the defaults in your projects, then you
don't have to worry about updating any Form code or DFMs manually,
since the values aren't used anywhere except inside the component's
internal code.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02