Grouping

I have some problems to read grid if grouped like:
Example in manual

United States | New York | 205000

United States | Chicago   | 121200
United States | Detroit      | 250011
Germany        | K?ln         | 420532
Germany        | Frankfurt  | 122557
Germany        | Berlin       | 63352

Grouped
- United States
New York | 205000 >> This values can I get, if row is selected, but how I can get "United States"?
Chicago   | 121200
Detroit      | 250011
- Germany
K?ln         | 420532
Frankfurt  | 122557 >> This values can I get, if row is selected, but how I can get "Germany"?
Berlin       | 63352

How can I get "United States" or "Germany" id I select one row?

Hi Matthias,

as you know the group works with node.

In order to get the group name you first have to get the current row, chek if it's node holder and if not go back to get the node holder.



This works for your need:



procedure TForm1.btn1Click(Sender: TObject);

Var R : Integer;

begin

R:=AdvStringGrid1.Row; // Current row

if AdvStringGrid1.IsNode(R) then // If is node holder... do nothing

Else

begin

    repeat

      R:=R - 1;

    until AdvStringGrid1.IsNode(R); // Go back to get node holder

end;

Lb1.Caption:=AdvStringGrid1.Cells[1,R]; // See node name

end;



Have a nice day

Daniele

Thanks, it works!!!