Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2011-08

Should StringGrid1.Clear clear the fixed rows / columns?

15 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

John Repucci

I have a fixed row in my SG with the titles for the columns, but when I do a SG.clear, the fixed rows are deleted.
I understand why that is happening (the so-called fixed rows are just row [0] within the SG).

However, it would be nice if the fixed rows were not affected by the clear. Am I missing something in the setup of the SG which would prevent the fixed row from being cleared or is this a bug or a potential enhancement request?

I could implement something like VirtualStringView/Tree and I am using that elsewhere in my program for another purpose, but I was looking for a lightweight grid.

0.9.31-31292-2.4.4-win32-Vista
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110731/142c4fee/attachment.html>

Reply by email

Graeme Geldenhuys
to John Repucci
John Repucci wrote
I have a fixed row in my SG with the titles for the columns, but when I do a SG.clear, the fixed rows are deleted.

I have raised that issue too. I believe what you have to do, is set the RowCount property to equal FixedRowCount - instead of calling Clear.

That kind of defeats the purpose of Clear, but hey it's Delphi compatible, so who cares. ;-)

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Alexander Klenin
to Graeme Geldenhuys
Graeme Geldenhuys wrote 10 lines
On 08/01/2011 03:10 AM, John Repucci wrote: > I have a fixed row in my SG with the titles for the columns, but when I > do a SG.clear, the fixed rows are deleted. I have raised that issue too. I believe what you have to do, is set the RowCount property to equal FixedRowCount - instead of calling Clear. That kind of defeats the purpose of Clear, but hey it's Delphi compatible, so who cares. ;-)

Adding optional parameter "AClearFixed: Boolean = true" to Clear may help without comprimising compatibility

Alexander S. Klenin

Reply by email

cobines
to John Repucci: I have a fixed row in my SG with the titles for the columns, but when I do a SG.clear,…

2011/8/1 John Repucci :

Show quoted text 6 lines
I have a fixed row in my SG with the titles for the columns, but when I do a SG.clear, the fixed rows are deleted. I understand why that is happening (the so-called fixed rows are just row [0] within the SG). However, it would be nice if the fixed rows were not affected by the clear.

Try:

SG.Clean([gzNormal]);
cobines

Reply by email

Graeme Geldenhuys
to cobines
cobines wrote
Try: SG.Clean([gzNormal]);

That clears the "text" content in cells. It doesn't remove associated Objects with each cell or row, and doesn't reduce the number of rows in the grid. So its behaviour is actually very different to Clear().

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Jesus Reyes
to Alexander Klenin: Adding optional parameter "AClearFixed: Boolean = true" to Clear may help without…

--- El lun 1-ago-11, Alexander Klenin escribi?:

Show quoted text 21 lines
De: Alexander Klenin Asunto: Re: [Lazarus] Should StringGrid1.Clear clear the fixed rows / columns? A: "Lazarus mailing list" Fecha: lunes, 1 de agosto de 2011, 2:25 On Mon, Aug 1, 2011 at 18:13, Graeme Geldenhuys wrote: > On 08/01/2011 03:10 AM, John Repucci wrote: >> I have a fixed row in my SG with the titles for the columns, but when I >> do a SG.clear, the fixed rows are deleted. > > I have raised that issue too. I believe what you have to do, is set the > RowCount property to equal FixedRowCount - instead of calling Clear. > > That kind of defeats the purpose of Clear, but hey it's Delphi > compatible, so who cares. ;-) >

I do care :).

Well I don't in this case as Delphi grids do not implement a clear method :D so this is not a compatibility problem, or is it?.

IIRC the problem you had with clear method is that after the clear you wanted the grid remembered your (fixed)cols/(fixed)rows layout. That was not planned for a cleared grid, because AFAIK, clear means dump everything, for example for a listbox means remove the items, not empty the items, then why should it remember it? however it seemed a good to have feature and I implemented it.

However, now you seem to suggest that calling clear should only mean clear the non fixed cells?, in this situation, if somebody has a grid with 2 fixed rows and 1 fixed column which was setup at design time with right titles, what should happen on grid.clear?, delete columns or rows? or just the non-fixed cells? At least I never seen a grid with just fixed cols/rows and no normal cells.

That is why "clear" is supposed to remove cols/rows and "clean" only cell content. Before anything, Delphi grids do not implement (that I know) a clean method, so this is not (or, not everything is) a compatibility problem :D

Adding optional parameter "AClearFixed: Boolean = true" to Clear may help without comprimising compatibility

That would solve a nonexistent problem, no need to implement something to remedy it.

-- Alexander S. Klenin

Jesus Reyes A.

Reply by email

John Repucci
Show quoted text 8 lines
From: Jesus Reyes ... Delphi grids do not implement a clear method :D so this is not a compatibility problem, or is it?. The add-on component VirtualStringView/Tree does implment a clear method

that does not delete the headers.

I can envision cases where I would like a completely empty SG and cases where I would like the fixed rows / columns to survive. ex 1: Instead of creating a 2nd SG with a completely different header structure and purpose, wipe the original, add in the desired new fixed cells and start to fill it.
ex: 2: (my current case...) Load in data, process it and then I need to purge the data, so I clear the SG and load in more data.

John

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110801/76306f63/attachment.html>

Reply by email

Jesus Reyes
to John Repucci

--- El lun 1-ago-11, John Repucci escribi?:

De: John Repucci
Asunto: Re: [Lazarus] Should StringGrid1.Clear clear the fixed rows / columns? A:
Fecha: lunes, 1 de agosto de 2011, 16:14

From: Jesus Reyes

... Delphi grids do not implement a clear method :D so this is not a compatibility problem, or is it?.

The add-on component VirtualStringView/Tree does implment a clear method that does not delete the headers. Lazarus grids never meant to be compatible with virtualstringview/tree.

I can envision cases where I would like a completely empty SG and cases where I would like the fixed rows / columns to survive.

ex 1: Instead of creating a 2nd SG with a completely different header structure and purpose, wipe the original, add in the desired new fixed cells and start to fill it.
you can do this after grid.clear, or simply grid.rowcount := grid.fixedrows and then change the columns titles
ex: 2: (my current case...) Load in data, process it and then I need to purge the data, so I clear the SG and load in more data.
you can do this with grid.rowcount := grid.fixedrows (which is btw unsupported in delphi AFAIK), no need to use clear method

John
Jesus Reyes A.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110801/cfcab4da/attachment.html>

Reply by email

Graeme Geldenhuys
to Jesus Reyes
Jesus Reyes wrote 5 lines
ex: 2: (my current case...) Load in data, process it and then I need to purge the data, so I clear the SG and load in more data. you can do this with grid.rowcount := grid.fixedrows (which is btw unsupported in delphi AFAIK), no need to use clear method

In my applications I use this second example a lot! I simply need to refresh the data, not the fixed headers. I think the problem comes in that Clear is confusing. Some expect one behaviour, you expect another. Maybe introduce another method ClearAll() that completely blanks the grid so it looks like a memo. Then change Clear to simply clear the grid but keep the fix rows. Or introduce a boolean parameter to Clear() like what was proposed earlier.

Yes I fully understand what you wanted Clear to mean - blank the whole grid. But clearly that is not what the Lazarus users expect. This is not the first time this issue was brought up [and surely not the last], so that is just proof of my previous sentence.

Just my 2? worth...

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

Unknown author
to Graeme Geldenhuys

2011/8/2 Graeme Geldenhuys :

Then change Clear to simply clear the grid but keep the fix rows.

what about keeping compatibility, many users will be surprised

Show quoted text 8 lines
Or introduce a boolean parameter to Clear() like what was proposed earlier. Yes I fully understand what you wanted Clear to mean - blank the whole grid. But clearly that is not what the Lazarus users expect. This is not the first time this issue was brought up [and surely not the last], so that is just proof of my previous sentence. Just my 2? worth...

I don't see the problem, current behavior of the Clear method is ok for me. This problem can be easily solved by setting StringGrid1.RowCount or StringGrid1.Rows[i].Clear.

Regards,
Tomek

Reply by email

Graeme Geldenhuys
to Unknown author
2011/8/2 Graeme Geldenhuys : > Then change Clear to simply clear the grid but keep the fix rows. what about keeping compatibility, many users will be surprised

Compatibility with what? Lazarus breaks compatibility with itself on a regular basis [in Trunk and between stable releases]. No developer would be surprised.

I don't use Lazarus LCL, but I do maintain the LCL support in tiOPF's MGM implementation. It constantly needs tweaking because LCL changes behaviour. So Lazarus LCL definitely has NO compatibility between versions!

Regards,
- Graeme -

fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/

Reply by email

John Repucci
to John Repucci: that does not delete the headers. I can envision cases where I would like a completely…
Show quoted text 20 lines
Date: Tue, 2 Aug 2011 13:36:20 +0200 From: Subject: Re: [Lazarus] Should StringGrid1.Clear clear the fixed rows / columns? To: Lazarus mailing list Message-ID: < > Content-Type: text/plain; charset=UTF-8 I don't see the problem, current behavior of the Clear method is ok for me. This problem can be easily solved by setting StringGrid1.RowCount or StringGrid1.Rows[i].Clear. Regards, Tomek The above works well for header ROWs, but not for a header COLUMN and will

not work in the case where both FixedRow and FixedColumn are being used and the user wishes to preserve them rather than rebuilding them everytime they want to clean up the SG.
- John
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110802/8adffb1d/attachment.html>

Reply by email

Unknown author
to John Repucci

2011/8/2 John Repucci :

The above works well for header ROWs, but not for a header COLUMN

same for cols -> StringGrid1.ColCount , StringGrid1.Cols[i].Clear

and will not work in the case where both FixedRow and FixedColumn are being used and the user wishes to preserve them rather than rebuilding them everytime they want to clean up the SG.

if both then the size will not change, so Clean method (with range) is enough (only one loop for SG.Objects if needed)

Regards,
Tomek

Reply by email

Jürgen Hestermann
to Hans-Peter Diettrich: I do not see the problem. Put the initialization code for the fixed rows/cols into a…
Show quoted text 9 lines
John Repucci schrieb: > The above works well for header ROWs, but not for a header COLUMN and > will not work in the case where both FixedRow and FixedColumn are > being used and the user wishes to preserve them rather than > rebuilding them everytime they want to clean up the SG. I do not see the problem. Put the initialization code for the fixed rows/cols into a subroutine, and call it whenever needed.

Not very elegant to repeat the initialization over and over again. This may lead to flicker and there is also the possibility that it is skipped because of unexpected procedure exit or whatever.

Reply by email

Hans-Peter Diettrich
to John Repucci: not work in the case where both FixedRow and FixedColumn are being used and the user…
The above works well for header ROWs, but not for a header COLUMN and will not work in the case where both FixedRow and FixedColumn are being used and the user wishes to preserve them rather than rebuilding them everytime they want to clean up the SG.

I do not see the problem. Put the initialization code for the fixed rows/cols into a subroutine, and call it whenever needed.

DoDi

Reply by email