TFMSFMXGrid Selected Rows ?

Hello the example dosen't work.


SelectionMode is smSingleRow

How can i find the rowindex of the selected row in the Grid?

I try two way's, but nothing works:

  function SelectRowCol():integer;
   var i : integer;
    begin
    for i := 0 to sgAnlage.RowCount - 1 do
      begin
         if sgAnlage.RowSelect then begin
           result := i;
           exit;
         end;
      end;
    end;

  function SelectRowCol2():integer;
   var i, rowindex : integer;
   begin
   result := 0;
   for i := 0 to sgAnlage.RowSelectionCount - 1 do begin
       result := sgAnlage.SelectedRow; // do something with the selected row rowindex here
       exit;
     end;
   end;

Regards 

Axel

Hi, 


With single row, you can use the TMSFMXGrid.FocusedCell method, which returns the focused cell column and row.

Kind Regards, 
Pieter

Hi Peter,


i only get the number 1 return:

z is integer;

   z := sgAnlage.FocusedCell.Row;

here the objectinspector:




Regards 

Axel

Hello Peter,


i found the problem, bevor i get the row i use:

   sgAnlage.UnHideColumn(0);

  z := sgAnlage.FocusedCell.Row;

when i use:

   z := sgAnlage.FocusedCell.Row;

   sgAnlage.UnHideColumn(0);

it works.

Regards

Axel