Board index » delphi » Obvious quick way to clear string grid?

Obvious quick way to clear string grid?

Quote
In article <4esljf$...@soap.news.pipex.net> f...@dial.pipex.com (Jamie R) writes:
>From: f...@dial.pipex.com (Jamie R)
>Subject: Obvious quick way to clear string grid?
>Date: Fri, 02 Feb 1996 09:30:21 GMT
>Does anyone know a better way to clear the string grid other than to
>place '' (empty string) in every cell? This is too obvious, not to
>mention {*word*76}y slow. Currently it can take seconds to empty a 300x15
>grid then refill it (I know i could overwrite it, but the size
>changes).
>I've tried reducing the number of cols and rows down to 1 and clearing
>that cell, then re -expanding but it stores all the data, and it's all
>back again (try it - it's spooky).
>Should I be doing something with the underlying array?
>I _must_ be doing s'thing wrong...
>Jamie.

Have you tried freeing it and then re-creating it ? May also be slow though

hth

Boris Ingram, Cyborg Software
boris...@iafrica.com
http://www.pcb.co.za/users/borising/cyborg.htm

 

Re:Obvious quick way to clear string grid?


Does anyone know a better way to clear the string grid other than to
place '' (empty string) in every cell? This is too obvious, not to
mention {*word*76}y slow. Currently it can take seconds to empty a 300x15
grid then refill it (I know i could overwrite it, but the size
changes).

I've tried reducing the number of cols and rows down to 1 and clearing
that cell, then re -expanding but it stores all the data, and it's all
back again (try it - it's spooky).

Should I be doing something with the underlying array?

I _must_ be doing s'thing wrong...

Jamie.

Re:Obvious quick way to clear string grid?


Take a look at the .Clear method for the .Rows property.

In article <4esljf$...@soap.news.pipex.net>, Jamie R

Quote
(f...@dial.pipex.com) writes: >Does anyone know a better way to clear

the string grid other than to >place '' (empty string) in every cell?
This is too obvious, not to >mention {*word*76}y slow.  Currently it can
take seconds to empty a 300x15 >grid then refill it (I know i could
overwrite it, but the size >changes).  >

Quote
>I've tried reducing the number of cols and rows down to 1 and clearing
>that cell, then re -expanding but it stores all the data, and it's all
>back again (try it - it's spooky).

>Should I be doing something with the underlying array?

>I _must_ be doing s'thing wrong...

>Jamie.

--
Chris Hanagan                   A society that will trade a
cbhan...@cbh.win.net            little liberty for a little
Key West, Florida               order will deserve neither
                                and lose both.
                                (Thomas Jefferson)

Re:Obvious quick way to clear string grid?


Quote
f...@dial.pipex.com (Jamie R) wrote:
>Does anyone know a better way to clear the string grid other than to
>place '' (empty string) in every cell? This is too obvious, not to
>mention {*word*76}y slow. Currently it can take seconds to empty a 300x15
>grid then refill it (I know i could overwrite it, but the size
>changes).
>I've tried reducing the number of cols and rows down to 1 and clearing
>that cell, then re -expanding but it stores all the data, and it's all
>back again (try it - it's spooky).
>Should I be doing something with the underlying array?

Hi,
Yes there is an easier way. There is a Cols[i].Clear method.
Cols are TStrings and TStrings have a Clear method. I tripped over
this by mistake one day. BTW I think the Rows property are TStrings
also. If you have fewer rows, Rows[i].Clear might be easier.

do this:

for i:=0 to MyGrid.ColCount-1 do MyGrid.Cols[i].Clear;

Barry.

/---------------------------------------------------------------\
| Check out CanalRun's WWW page http://www.vcomm.net/~canalrun/ |
| Education, Investment, Personal Productivity Shareware.       |
\---------------------------------------------------------------/

Re:Obvious quick way to clear string grid?


Quote
Jamie R wrote:
> Does anyone know a better way to clear the string grid other than to
> place '' (empty string) in every cell? This is too obvious, not to
> mention {*word*76}y slow. Currently it can take seconds to empty a 300x15
> grid then refill it (I know i could overwrite it, but the size
> changes).

Here's little bit shorter way to clear StringGrid:

  for i := 0 to StringGrid1.RowCount - 1 do
    StringGrid1.Rows[i].Clear;

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Ari Hirviniemi, Lappeenranta, Finland (ari.hirvini...@ktieto.fi)
All my opinions and comments are personal and have nothing to do
with my employer.

Other Threads