PeterLarsen
asked on
Clear all rows in a TStringGrid ??
How can i clear some or all rows in a tstringgrid.
I dont want to use the command 'stringgrid1.rows[xx].clea r'.
I dont want to use the command 'stringgrid1.rows[xx].clea
Their is severel ways to do this
1) You might clear the actual cell texts
2) Set the StringGrid1.RowCount to minimum
3) Set the StringGrid1.ColCount to minimum
To clear all the cell properties do like:
For i:= 0 to StringGrid1.RowCount-1 do
For j:= 0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[j,i]:= '';
Regards,
Williams
1) You might clear the actual cell texts
2) Set the StringGrid1.RowCount to minimum
3) Set the StringGrid1.ColCount to minimum
To clear all the cell properties do like:
For i:= 0 to StringGrid1.RowCount-1 do
For j:= 0 to StringGrid1.ColCount-1 do
StringGrid1.Cells[j,i]:= '';
Regards,
Williams
Hmmm. Why not?
I meant, why don't you want to use 'stringgrid1.rows[xx].clea r'?
If you have problems with that URL (actually I have them at the moment) then you
can try it at Torry's Delphi Pages:
http://www.torry.ru/vcl/grids/hyperd2.zip (Delphi 2)
http://www.torry.ru/vcl/grids/hyperd3.zip (Delphi 3)
http://www.torry.ru/vcl/grids/hyperd4.zip (Delphi 4)
Cheers, Tulip
can try it at Torry's Delphi Pages:
http://www.torry.ru/vcl/grids/hyperd2.zip (Delphi 2)
http://www.torry.ru/vcl/grids/hyperd3.zip (Delphi 3)
http://www.torry.ru/vcl/grids/hyperd4.zip (Delphi 4)
Cheers, Tulip
ASKER
First, thanks to all. I posted my question 5 min ago...
Tulip : I must use standard components in this project.
William : I want to clear 500000 rows (sometime more). By using 'stringgrid.rows[xx].clear ' -it takes too long time to clear so many rows.
Regards
PL
Tulip : I must use standard components in this project.
William : I want to clear 500000 rows (sometime more). By using 'stringgrid.rows[xx].clear
Regards
PL
Well, then destroy grid and create a new one .
ASKER
First, thanks to all. I posted my question 5 min ago...
Tulip : I must use standard components in this project.
William : I want to clear 500000 rows (sometime more). By using 'stringgrid.rows[xx].clear ' -it takes too long time to clear so many rows.
Regards
PL
Tulip : I must use standard components in this project.
William : I want to clear 500000 rows (sometime more). By using 'stringgrid.rows[xx].clear
Regards
PL
Well, then destroy the grid and create a new one. That's brute but fast.
Tulip
Tulip
Well, then destroy the grid and create a new one. That's brute but fast.
Tulip
Tulip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I would say that you'll have to make a custom handing more like having your own datastructure build together with an ownerdrawn grid
Regards,
Williams
Regards,
Williams
ASKER
Hi Raymond and thanks..
Your idea is fine but.... The application-stringgrid reads its data from either a local CDRom or the Internet.
When reading from the Internet, the data has to be stored somewhere in the system (a type of Record or TstringList), otherwise the system is getting very slow. Its takes up memory - each row (4 byte) + each record (?? byte).
I am using OnDrawCell to draw colors others than windows standard colors - so this part i easy.
Your idea may be the only way to do this - i don't know. It takes some re-programming to emplement your idea.
It may also slow down the system to dynamic create+destroy the so many records.
regards, PL
Your idea is fine but.... The application-stringgrid reads its data from either a local CDRom or the Internet.
When reading from the Internet, the data has to be stored somewhere in the system (a type of Record or TstringList), otherwise the system is getting very slow. Its takes up memory - each row (4 byte) + each record (?? byte).
I am using OnDrawCell to draw colors others than windows standard colors - so this part i easy.
Your idea may be the only way to do this - i don't know. It takes some re-programming to emplement your idea.
It may also slow down the system to dynamic create+destroy the so many records.
regards, PL
Well, you have to read the information anyway, the only difference is instead of injecting it into the string grid you would store it on disk, or perhaps create a TList descendent that stored objects, each of which stored the information for a row (or you could even use a DynamicArray).
The options are certainly there, though I don't think it would be a lot of work to change it.
Cheers,
Raymond.
The options are certainly there, though I don't think it would be a lot of work to change it.
Cheers,
Raymond.
ASKER
Well, there are more than 20.000 lines of code in 25 units. I may have to change 10-20 % of the code. :(
But - sometimes you have to change a lot - to make it perfect.
Regards, PL.
But - sometimes you have to change a lot - to make it perfect.
Regards, PL.
for i := 0 to StringGrid1.RowCount-1 do StringGrid1.Rows[i].Clear;
But I don't use StringGrid. There is a better one available, called HyperGrid.
There you can call HyperGrid1.Clear or even define an area (from..to) to clear.
You can find it at: http://www.pablop.demon.co.uk/
Cheers, Tulip