Group and real column index

I have a grid with group enabled.
There are 8 Columns.
In grid events (for example OnGetAlignment)
the ACol value refers to the visible columns (the event is triggered for columns from 0 to 6, never for 7)
When ACol = 6 is talking about the last column that i'm exptecting is 7.
I've tryed to use RealColIndex to get the right column index, but it returns the same value passed.
As the grid can be grouped or not, I need to be sure of what column ACol is.

What I need is a function that return the correct column index.
When grid is grouped: if ACol = 6 the funtion must return 7
When grid is NOT grouped: if ACol = 6 the function must return 6

Thanks
Claudio Basso

There is not a built-in function in the grid to automatically do this conversion.
You can use the helper function:


function gridcol(grid: TAdvStringGrid; col: Integer): Integer;
begin
  if (grid.GroupColumn >= 0) and (col >= grid.GroupColumn) then
    Result := col - 1
  else
    Result := col;
end;

It's what I was thinking of, it works.

Thanks