title: Delphi TDBGrid selected row get value
body: <p>I would like to retrieve a value from a TDBGrid the selected row, how can I do?</p>
  
  <pre><code>procedure TForm7.Button2Click(Sender: TObject);
      var
        i, j: Integer;
        s: string;
      begin
        if DBGrid1.SelectedRows.Count&gt;0 then
          with DBGrid1.DataSource.DataSet do
            for i:=0 to DBGrid1.SelectedRows.Count-1 do
            begin
              GotoBookmark(DBGrid1.SelectedRows.Items[i]);
              for j := 0 to FieldCount-1 do
              begin
                if (j&gt;0) then s:=s+', ';
                s := s + FindField(Fields.Fields[j].FieldName).AsString;
              end;
              Listbox1.Items.Add(s);
              s:= '';
            end;
      end;
  </code></pre>