?
Solved

TStringGrid.Clear (deletes all cells in a stringgrid)

Posted on 2003-10-26
10
Medium Priority
?
6,198 Views
Last Modified: 2007-12-19
I need a method ("Clear") that clears all cells of a string grid and then deletes them.

So stringgrid.Clear finally DELETES ALL CELLS (ROWS/COLS..whatever you like) of the stringgrid.

Thx.
0
Comment
Question by:Catalin80
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9623277
just set the rowcount- and colcount-properties to 0 (zero)

meikl ;-)
0
 

Author Comment

by:Catalin80
ID: 9625942
Already tryed that. Doesn't work. (delphi6)
0
 

Author Comment

by:Catalin80
ID: 9625954
There is still 1 cell left.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:huferry
ID: 9625962
Do you meant the content only?

procedure ClearStringGrid(Grid: TStringGrid);
var
  I: Integer;
  J: Integer;
begin
  for I := 0 to Grid.ColCount-1 do
    for J := 0 to Grid.RowCount-1 do
      Grid.Cells[I,J] := '';
end;
0
 

Author Comment

by:Catalin80
ID: 9626412
The content AND the CELLS. I need one tstringgrid WITH NO CELLS. If that isn't possible then I just can hide the entire table.
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9626550
there allways one cell!
you can't get rid of it
0
 

Author Comment

by:Catalin80
ID: 9626901
Ok. but what was that about "colcont=0;rowcount=0" ?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 9626919
>but what was that about "colcont=0;rowcount=0" ?
that deletes the whole content from the grid,
that one cell left is a default painting bahaviour, if the grid is empty
-> maybe this could be adjusted by using ownerdraw

meikl ;-)
0
 
LVL 3

Accepted Solution

by:
huferry earned 100 total points
ID: 9632430
if the grid is empty, just make it invisible. Then you'll have no cell at all.

0
 
LVL 2

Expert Comment

by:gangsterboss
ID: 9647093
try setting the stringgrids visible property to false when u want to get rid of them all
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question