Board index » delphi » String Grid Question

String Grid Question

Hi, and TIA:

Lets say I have a string grid called alpha. Say I add 26 entries to it
(A,B,C,D). At certain times, I only want to display A-M, or 13
entries. If I set alpha.RowCount := 13,  is the memory that was
reserved for the next 13 entries released; that is, can other
processes overwrite these 13 slots, or would it be safe to later
change the rowcount back to 26, and assume that no other processses
have access to this memory?  As it is, if I change it back to 26, then
Alpha.Cells[0,13], say, is still N, but I don't know if it is secure,
of if I should re-Add cells 13-25.

THanks again
{*word*106} Kerrigan

 

Re:String Grid Question


It's best not to rely on it.

<dkerr-ill-take-your-s...@slip.net> skrev i en
nyhedsmeddelelse:37d57b2e.134113...@news.slip.net...

Quote
> have access to this memory?  As it is, if I change it back to 26, then
> Alpha.Cells[0,13], say, is still N, but I don't know if it is secure,

Re:String Grid Question


dkerr-ill-take-your-s...@slip.net schrieb:

Quote

> Hi, and TIA:

> Lets say I have a string grid called alpha. Say I add 26 entries to it
> (A,B,C,D). At certain times, I only want to display A-M, or 13
> entries. If I set alpha.RowCount := 13,  is the memory that was
> reserved for the next 13 entries released; that is, can other

Yes, it is.

Quote
> processes overwrite these 13 slots, or would it be safe to later
> change the rowcount back to 26, and assume that no other processses

You can change back to 26 or any other number later. Accessing memory by
other processes is not relevant here. If rowcount increases, new memory
is assigned for the new rows.

Quote
> have access to this memory?  As it is, if I change it back to 26, then
> Alpha.Cells[0,13], say, is still N, but I don't know if it is secure,
> of if I should re-Add cells 13-25.

The cell will be empty, and you have to re-Add Values

-Michael

Re:String Grid Question


In article <37d57b2e.134113...@news.slip.net>,

Quote
dkerr-ill-take-your-s...@slip.net writes:
>Lets say I have a string grid called alpha. Say I add 26 entries to it
>(A,B,C,D). At certain times, I only want to display A-M, or 13
>entries. If I set alpha.RowCount := 13,  is the memory that was
>reserved for the next 13 entries released; that is, can other
>processes overwrite these 13 slots, or would it be safe to later
>change the rowcount back to 26, and assume that no other processses
>have access to this memory?  As it is, if I change it back to 26, then
>Alpha.Cells[0,13], say, is still N, but I don't know if it is secure,
>of if I should re-Add cells 13-25.

Why don't you write a bit of code and find out yourself, or look at the
TStringGrid source. If you then hit apparent problems, ask questions here.

Not only wll you learn more about string-grids, you will encourage people to
spend time helping you. At the moment I don't feel like helping someone who
appears unwilling to even _try_ and find out himself.

Alan Lloyd
alangll...@aol.com

Re:String Grid Question


On Wed, 08 Sep 1999 07:50:53 +0200, Michael Winter <m...@aquila.de>
Quote

>You can change back to 26 or any other number later. Accessing memory by
>other processes is not relevant here. If rowcount increases, new memory
>is assigned for the new rows.

>>The cell will be empty, and you have to re-Add Values

Well, no, actually, the stuff that was stored there is still there, so
if it is allocating new memory, it is happenstantially the same memory
locations that it had previously allocated.  Here is a snipped version
of the actual call:
  If mnuScrollOn.Caption = '&Start Scroll' THEN BEGIN
      sgDisplay.RowCount := 2 * sgDisplay.RowCount ;  
     mnuScrollOn.Caption := '&Stop Scroll';
     end
    else begin
     sgDisplay.RowCount := RecordCount + 1;
     mnuScrollOn.Caption := '&Stop Scroll';
   end;

This works, and I haven't seen any strange problems in 2 years, but I
don't trust it.  If it matters, it's 16 bit code.

I think I'll just rebuild the display, although there's a time penalty
involved.

Thanks for the input,
DK

Re:String Grid Question


dkerr_hates_potted_p...@slip.net schrieb:

Quote

> On Wed, 08 Sep 1999 07:50:53 +0200, Michael Winter <m...@aquila.de>

> >You can change back to 26 or any other number later. Accessing memory by
> >other processes is not relevant here. If rowcount increases, new memory
> >is assigned for the new rows.

> >>The cell will be empty, and you have to re-Add Values

> Well, no, actually, the stuff that was stored there is still there, so
> if it is allocating new memory, it is happenstantially the same memory
> locations that it had previously allocated.  Here is a snipped version
> of the actual call:

[snip]

Surprisingly, my statements were wrong. Decreasing RowCount does *only*
decrease the number of *visible* rows, not the number of allocated rows.
So your code should be safe. Another surprise for me was that the OH
stated that Rows is a TStrings, but it isn't. That is, you can not ask
for Rows.Count. It's only a indexed property of type String. So there
seems to be no possibility to reduce allocated space. Even that thing
does not have a Clear method. I begin to hate it...
-Michael

Re:String Grid Question


Thanks for the response -- sorry to be so long gone, but I was having
server problems . . .

Yeah, I found a reference in Lishner's Secrets of D2 that said just
what you said, and what I was running into. Of course, for me, this is
just the ticket, what I need -- It has the effect of making the end of
the grid invisible.

Anyway, thanks again for the help
DK

Other Threads