unit uGridUtils;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxCustomData, cxGraphics, cxFilter, cxData,
  cxDataStorage, cxEdit, DB, cxDBData, cxGridLevel,
  cxClasses, cxControls, cxGridCustomView, cxGridCustomTableView,
  cxGridTableView, cxGridDBTableView, cxGrid,
  uDBSelectionListUtils;


procedure SeleccionarFilasDesdeGrid(const AView : TcxCustomGridView;
  ASelectedRowList : TSelectedRecords);

implementation


uses
  uDADataTable, uDAInterfaces;

procedure SeleccionarFilasDesdeGrid(const AView : TcxCustomGridView;
    ASelectedRowList : TSelectedRecords);
var
  ACurrentRecord : Integer;
  ADataTable : TDADataTable;
  ABookmark : Pointer;
  ARecord: TcxCustomGridRecord;
  i : Integer;
begin
  // Fila actual del grid
  ACurrentRecord := TcxCustomGridTableController(AView.Controller).FocusedRecordIndex;

  ShowHourglassCursor;
  AView.BeginUpdate;
  try
    ASelectedRowList.Clear;
    for i := 0 to TcxCustomGridTableController(AView.Controller).SelectedRecordCount - 1 do
    begin
      ARecord := TcxCustomGridTableController(AView.Controller).SelectedRecords[i];
      if (ARecord is TcxGridDataRow) then
      begin
        (ARecord as TcxGridDataRow).Focused := True;
        ASelectedRowList.CurrentRowSelected := True;
      end;
    end;
    TcxCustomGridTableController(AView.Controller).FocusedRecordIndex := ACurrentRecord;
  finally
    AView.EndUpdate;
    HideHourglassCursor;
  end;
end;


end.
