Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: StringGrid Update



Permlink Replies: 4 - Last Post: Mar 27, 2018 10:51 AM Last Post By: Peter Below
Doulgas Keene

Posts: 44
Registered: 1/17/01
StringGrid Update
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 25, 2018 4:42 AM
Hello

Is there a way to use BeginUpdate and EndUpdate for a StringGrid while processing lengthy operations so that the user interface does not appear frozen?

Thanks
DK
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: StringGrid Update
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 25, 2018 10:48 AM   in response to: Doulgas Keene in response to: Doulgas Keene
Doulgas Keene wrote:

Hello

Is there a way to use BeginUpdate and EndUpdate for a StringGrid
while processing lengthy operations so that the user interface does
not appear frozen?

Yes.

stringgrid1.Rows[0].BeginUpdate;
try
...stuff
finally
stringgrid1.Rows[0].EndUpdate;
end;

--
Peter Below
TeamB
Doulgas Keene

Posts: 44
Registered: 1/17/01
Re: StringGrid Update
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 26, 2018 7:34 AM   in response to: Peter Below in response to: Peter Below
Thanks, Peter
would be nice if there were a way to beginupdate and endupdate the entire stringgrid

Peter Below wrote:
Doulgas Keene wrote:

Hello

Is there a way to use BeginUpdate and EndUpdate for a StringGrid
while processing lengthy operations so that the user interface does
not appear frozen?

Yes.

stringgrid1.Rows[0].BeginUpdate;
try
...stuff
finally
stringgrid1.Rows[0].EndUpdate;
end;

--
Peter Below
TeamB
Alex Belo

Posts: 626
Registered: 10/8/06
Re: StringGrid Update
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 26, 2018 11:54 PM   in response to: Doulgas Keene in response to: Doulgas Keene
Doulgas Keene wrote:

Is there a way to use BeginUpdate and EndUpdate for a
StringGrid while processing lengthy operations so that the user
interface does not appear frozen?

would be nice if there were a way to beginupdate and endupdate the
entire stringgrid

Then you need to define "the user interface does not appear frozen".

If you need to process a lot of lines in, say, 10 sec then what user
should do while processing is in progress:

- continue entering data into the same grid;
- do something else.

The first option looks quite complicated, the second one is quite
simple:

1) disable stringgrig in question to prevent user's input here;
2) start a secondary thread (with TThread descendant), process your
data line by line in background (Thread.Execute);
3) output processed lines (with Sinhcronize) line by line or by
appropriate chanks (every 100 ms, for example);
4) enable grid, for example, in Thread.OnTerminate event.

--
Alex
Peter Below

Posts: 1,227
Registered: 12/16/99
Re: StringGrid Update
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 27, 2018 10:51 AM   in response to: Doulgas Keene in response to: Doulgas Keene
Doulgas Keene wrote:

Thanks, Peter
would be nice if there were a way to beginupdate and endupdate the
entire stringgrid

But the code I gave you does exactly that, it not only blocks updates
to the given row. The rows and columns properties of the grid return
objects that are derived from TStrings, so they inherit the
BeginUpdate/endUpdate mechanism. Internally the implementation is quite
different from, say, TStringgrid, though, and the update methods are
implemented by sending Wm_SETREDRAW messages to the grid. These affect
the complete client area of the grid, not only one row or column.



Peter Below wrote:
Doulgas Keene wrote:

Hello

Is there a way to use BeginUpdate and EndUpdate for a StringGrid
while processing lengthy operations so that the user interface
does not appear frozen?

Yes.

stringgrid1.Rows[0].BeginUpdate;
try
...stuff
finally
stringgrid1.Rows[0].EndUpdate;
end;

--
Peter Below
TeamB


--
Peter Below
TeamB

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02