Article View: borland.public.cppbuilder.nativeapi
Article #1675Best way to clear a stringgrid?
From: Dan
Date: Thu, 28 Jun 2007 13:46
Date: Thu, 28 Jun 2007 13:46
34 lines
1901 bytes
1901 bytes
Hi, I want to clear a string grid, and I'd like to do it quickly.
What is the best way to do that?
The problem that I am having is that for REALLY LARGE grids, clearing
the grid takes a long time. I'd like to see quick performance like I
see when I close the app. Would it be best to delete the grid and
recreate it instead?
This is my code:
void ClearStringGrid(TStringGrid* sgGrid)
{
const bool OldVisible = sgGrid->Visible;
sgGrid->Visible = false;
Application->ProcessMessages();
for (int Row = 0; Row< sgGrid->RowCount; Row++)
{
for (int Col = 0; Col< sgGrid->ColCount; Col++)
{
//this process is slow, but needed
//if I don't do this, and just change the col/row counts
//then the cells may still have values.
sgGrid->Cells[Col][Row] = "";
sgGrid->Objects[Col][Row] = NULL;
}
}
sgGrid->ColCount=0;
sgGrid->RowCount=0;
sgGrid->ColWidths[0] = 50;
sgGrid->Cells[0][0] = "";
sgGrid->Visible = OldVisible;
}
Technical Details
Message-ID:
<4683bbbe$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!64.192.187.27!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,dbe415a5e9add767,start X-Google-Attributes: gid10cc67,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Date: Thu, 28 Jun 2007 08:46:41 -0500 From: Dan <Dan@do.not.spam> User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: Best way to clear a stringgrid? Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 72.254.156.114 Message-ID: <4683bbbe$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1183038398 72.254.156.114 (28 Jun 2007 06:46:38 -0700) Lines: 34 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wns14feed!worldnet.att.net!64.192.187.27!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail