Empty a StringGrid

Hello,

How do I empty or clear a StringGrid?

(Like the Edit Box where you have the property Clear).

I have until now solved it with a Loop where I empty all visible cells (cell by cell for every row), but that doesn't work very well since I don't know, at the "empty point", how large the grid is going to be in the future (the, for the moment, unvisible cells doesn't get emptied).

Kind Regards/ Henrik
swghewcAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

intheCommented:
hi,
you can do like:

procedure TForm1.Button1Click(Sender: TObject);
var
i : integer;
begin
for i := 0 to stringgrid1.Rows[0].Count -1
do begin
stringgrid1.rows[i].clear;
end;
end;

Regards Barry
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EpsylonCommented:
Here are 2 ways to clear the entire grid:

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

  with StringGrid1 do
    for i := 0 to ColCount - 1 do
      Cols[i].Clear;
0
EpsylonCommented:
Sorry Barry, didn't see your answer......
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

intheCommented:
hi epsylon,
long time no read
hope you had good xmas and new year :-)
0
EpsylonCommented:
Well I have but I wish it was 1900 so I would have more time to do the thing I need to do    :o)
0
GurkanCommented:
I have a faster solution if u'd like unlock this question
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.