10177 : In VCL I want catch change of the active row in the grid to get the values of the grid level and the values of some grid columns…

Question

I have a Gantt with a GridTree with 3 levels.

I want when I change the active row of the grid tree to get the values of the grid level and the values of some grid columns. Can you tell me what event should I use and what is the exact syntax in order to achieve this?

Answer

In the VCL version:

Assign the event phGant.Grid.OnSelectionChanged and implement like this:

procedure TForm1.GridSelectionChanged(Sender: TObject);
var
  aNode:TphDataEntity_GridTreeNode;
  aBabCell:TBabCell;
begin
  if Assigned(phGant1.Grid.FocusedCell) then
  begin
    aNode:=phGant1.Grid.CellToNode(phGant1.Grid.FocusedCell)
    aNode.Level;  // Grid level
    aBabCell:=phGant1.Grid.Cell[X,aNode.AxisContentItem.ListIndex]; // Any cell in the X direction
    phGant1.Grid.GetText(aBabCell); // The text value of the cell
  end;
end;

Leave a Reply