I have a TAdvStringGrid and I hide one of the Cells with the GetDisplText event like this:
procedure TForm1.AdvSGlicentiesGetDisplText(Sender: TObject; ACol,
ARow: Integer; var Value: string);
begin
if ACol = AdvSGlicenties.ColumnPosition(3) then
begin
Value := '';
end;
end;
When I use GridCells to read the value in the cell this does not work, I always get an empty string:
cValue := AdvSGlicenties.GridCells[3, AdvSGlicenties.SelectedRow[0]];
When I don't use the GetDisplText event it works allright, so I guess GridCells does not work as it should.
I have tested this here with a default grid on the form and the code:
procedure TForm5.AdvStringGrid1GetDisplText(Sender: TObject; ACol,
ARow: Integer; var Value: string);
begin
if acol = 3 then
Value := '';
end;
procedure TForm5.Button1Click(Sender: TObject);
begin
caption := advstringgrid1.GridCells[3,1];
end;
procedure TForm5.FormCreate(Sender: TObject);
begin
advstringgrid1.LinearFill(false);
end;
and I cannot see a problem here. What's different in your project?
I don't use 'linearfill'. What's that? It's not explained in the manual.
I also use this for column 3:
AdvSGlicenties.AddImageIdx( 3, nTeller + 1, 16, haCenter, vaCenter);
AdvSGlicenties.AddComment( 3, nTeller + 1, 'Licentie uitgeschakeld');
LinearFill is just a helper method to fill the grid with test data with a single method.
The problem was due to AddImageIdx & AddComment. As a workaround, assign the OnGetDisplText event only after calling AddImageIdx & AddComment.
In the next update, this issue will be fixed.