AdvGrid Hidden column

Hi,

i have a strange problem in grid with hidden column.

For my need i have a hidden column (is the last grid's column) where i store some text, this text is showed in a advmemo component.

Assuming a grid with 5 rows, only rows 3 and 4 have comment stored in hidden column.

Grid now point to row 4 (with the comment), the memo shows the text stored in that cell.

When i delete this row (number 4) with Grid.RemoveRows(Grid.Row,1) the grid remove this "line", i refresh the memo but, instead to get an empty memo, i have the old comment (stored in the deleted row).

I tryed with Grid.UnHideCol(3) before deleteing the row but with no result.

The only way to remove the cell's text is check if is present and delete it

If Grid.Cells[3,Grid.Row]<>'' then Grid.Cells[3,Grid.Row]:='';

Grid.RemoveRows(Grid.Row,1)



Where i wrong ??



Thank's and have a good day



Daniele

I try to understand what you are doing but I can't see such a problem here. Perhaps there is some information missing?


Test code on a default grid:

procedure TForm1.AdvStringGrid1ClickCell(Sender: TObject; ARow, ACol: Integer);
begin
  memo1.Lines.Text := advstringgrid1.AllCells[4, ARow];
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  advstringgrid1.RemoveRows(advstringgrid1.Row,1);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  advstringgrid1.RandomFill(false);
  advstringgrid1.AutoNumberCol(1);
  advstringgrid1.ClearCols(4,1);

  advstringgrid1.Cells[4,1] := 'x';
  advstringgrid1.Cells[4,4] := 'x';
  advstringgrid1.Cells[4,7] := 'x';
  advstringgrid1.HideColumn(4);
end;

When clicking a row, this displays 'x' when needed in the memo. When a row is removed that has value 'x' in column 4 and clicking it again to check, the 'x' is no longer in the memo (because the clicked happened on the row that moved a position up to replace the removed row)
Hi,

i have the same problem.
When we remove a row, its cells value on hidden column are not deleted and will be assigned to row + 1 that will be accessed as Row.

In fact, the hidden cells value on row below the row that we delete will be lost and we will have cells value from the row that have been deleted.


Regards,
Mauricio

I cannot reproduce this.
Was tested with a default grid and the code:

begin
  advstringgrid1.LinearFill(false);
  advstringgrid1.HideColumn(2);
  advstringgrid1.RemoveRows(4,1);
  advstringgrid1.UnHideColumnsAll;
end;

After unhiding the columns again,the grid data is all as expected.


Bruno Fierens2019-07-17 12:10:46
Hi

i have found my problem:
my hidden column index is 19. 

I have colCount to 19 instead of 20.

Problem solved!
Sorry :)


Hi Bruno,

thank's for reply.

Problem solved.

Thank's

Daniele