Lazarus

Programming => LCL => Topic started by: airpas on March 24, 2014, 07:25:31 am

Title: TStringGrid & Row number
Post by: airpas on March 24, 2014, 07:25:31 am
Hi
how to fill the first column with numbers automatically , starting from 1 to RowCount ?

thanks
Title: Re: TStringGrid & Row number
Post by: Blaazen on March 24, 2014, 08:52:55 am
There's property for this: TStringGrid.Options-> goFixedRowNumbering
Title: Re: TStringGrid & Row number
Post by: airpas on March 24, 2014, 10:44:17 am
thanks Blaazn
but seems setting a large number of rows caused a poor performance .
for example 1million rows , slow down the execution time by (in my pc 2 second) and eat 120Mb of memory .

MSEGUI seems much optimized , the same example execute faster and eat only 20Mb

Title: Re: TStringGrid & Row number
Post by: karaba on March 24, 2014, 11:12:37 am
err How many rows do you have? 120MB just by enabling one option? Are you sure?
Title: Re: TStringGrid & Row number
Post by: engkin on March 24, 2014, 11:48:24 am
err How many rows do you have? 120MB just by enabling one option? Are you sure?
The OP already said "1million rows"
Title: Re: TStringGrid & Row number
Post by: karaba on March 24, 2014, 11:52:51 am
err How many rows do you have? 120MB just by enabling one option? Are you sure?
The OP already said "1million rows"

Oops speed reading and meased it sorry.
Title: Re: TStringGrid & Row number
Post by: BigChimp on March 24, 2014, 12:08:41 pm
Who wants to display 1 million rows in a standard grid? AFAIR the grid wasn't designed for this and you'd need to have a custom virtual grid that saves/loads data to be displayed on the fly...
Title: Re: TStringGrid & Row number
Post by: engkin on March 24, 2014, 01:05:07 pm
Who wants to display 1 million rows in a standard grid?
I don't know.

AFAIR the grid wasn't designed for this
RowCount being of type integer implies that you can use any integer value. One million is, relatively speaking, a small number compared to MaxInt (2147483647)  :P

and you'd need to have a custom virtual grid that saves/loads data to be displayed on the fly...
I agree.
Title: Re: TStringGrid & Row number
Post by: BigChimp on March 24, 2014, 01:15:24 pm
AFAIR the grid wasn't designed for this
RowCount being of type integer implies that you can use any integer value. One million is, relatively speaking, a small number compared to MaxInt (2147483647)  :P
Well yes, the OP indicates it does seem to work... for a given definition of "work" i.e. depending on your performance requirements ;)
Title: Re: TStringGrid & Row number
Post by: airpas on March 24, 2014, 02:33:46 pm
it is just a notice come from a simple test.
there should be a limit of row counts , since 1million caused notable slowdown  and as engkin said , RowCount is an integer type so it maybe more than millions .
Title: Re: TStringGrid & Row number
Post by: zeljko on March 24, 2014, 02:40:06 pm
err How many rows do you have? 120MB just by enabling one option? Are you sure?

For visualisation of such huge amound of data you can use TVirtualStringTree. TStringGrid isn't right component to do that.
Title: Re: TStringGrid & Row number
Post by: BigChimp on March 24, 2014, 02:41:01 pm
there should be a limit of row counts
Are you sure?

Patches welcome... would be interested to see how you intend to calculate that limit (especially given the speed differences between e.g. aRaspberry Pi versus multiple core desktop machines)... or whether you want to have a constant number.
Title: Re: TStringGrid & Row number
Post by: tk on April 07, 2014, 10:06:31 am
Maybe the KGrid could help you with the goVirtualGrid option.
http://tkweb.eu/en/delphicomp/kgrid.html
You can generate the numbers yourself in the OnDrawCell event and this will be fast even for millions of lines.

TK.
TinyPortal © 2005-2018