Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Reading value of cells in a grid
Sat, Jan 30 2021 11:32 AMPermanent Link

Ronald

Hi,

I have a TGrid that is populated with data. I try to read the values

Showmessage(Grid1.Rows.Row[0].Value[0]);

But I keep getting the message:

Error. List index 0 out of bounds

Line 1

What is wrong with my code?

Ronald
Sat, Jan 30 2021 12:45 PMPermanent Link

Raul

Team Elevate Team Elevate

On 1/30/2021 11:32 AM, Ronald wrote:
> I have a TGrid that is populated with data. I try to read the values
>
> Showmessage(Grid1.Rows.Row[0].Value[0]);
>
> But I keep getting the message:
>
> Error. List index 0 out of bounds
>
> Line 1
>
> What is wrong with my code?
>

This should work in general.

Is this bound or unbound and how are you populating it  ?

I can duplicate the error with unbound if I set RowCount manually and
then go and edit the cells (they are set as edits).

Adding rows properly with "grid.InsertRow" works OK.

Either it's a bug (if one can use RowCount to increase number of rows)
or RowCount should be read-only property.

Raul
Sun, Jan 31 2021 4:26 AMPermanent Link

Ronald

Raul wrote:

>Either it's a bug (if one can use RowCount to increase number of rows)
>or RowCount should be read-only property.

Thanks Raul,
I forgot to say it is in EWB2, so worries about EWB3.
It must have somtething to do with my code elsewhere because I used it before and it worked perfectly. Ii will continue my search.
Sun, Jan 31 2021 12:04 PMPermanent Link

Raul

Team Elevate Team Elevate

On 1/31/2021 4:26 AM, Ronald wrote:
> I forgot to say it is in EWB2, so worries about EWB3.
> It must have somtething to do with my code elsewhere because I used it before and it worked perfectly. Ii will continue my search.

Same questions though as same applies to EWB2 and

If unbound make sure you use Grid1.AppendRow and then
Grid1.Rows.Row[0].Value[0] should work ok

Raul

Tue, Feb 2 2021 11:47 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Raul,

<< I can duplicate the error with unbound if I set RowCount manually and then go and edit the cells (they are set as edits). >>

This is now fixed and the fix will be in 3.00 B2.

Thanks !

Tim Young
Elevate Software
www.elevatesoft.com
Tue, Feb 2 2021 11:49 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Raul,

Hot fix:

WebGrids.wbs unit fixed method:

procedure TGridRows.SetCount(Value: Integer);
var
  I: Integer;
  TempRow: TGridRow;
begin
  FList.BeginUpdate;
  try
     if (Value > FList.Count) then
        begin
        for I:=(FList.Count+1) to Value do
           begin
           TempRow:=TGridRow.Create(Self,NextRowID);
           TempRow.SetCount(FColumnCount);
           FList.Add(TempRow);
           end
        end
     else if (Value < FList.Count) then
        begin
        for I:=FList.Count-1 downto Value do
           FList.Delete(I);
        end;
  finally
     FList.EndUpdate;
  end;
end;

Tim Young
Elevate Software
www.elevatesoft.com
Image