unit GridRowSelection;

interface

uses
  Classes, SysUtils, IWAppForm, IWApplication, IWTypes, IWWebGrid,
  IWDBAdvWebGrid, DB, DBTables, IWDBStdCtrls, IWCompButton, Controls,
  IWBaseControl, IWControl, IWCompLabel, LeftFrame, Forms, TopFrame,
  IWVCLBaseControl, IWBaseHTMLControl, ADODB, IWCompListbox;

type
  TformGridRowSelection = class(TIWAppForm)
    IWLabel1: TIWLabel;
    IWButton1: TIWButton;
    IWDBNavigator1: TIWDBNavigator;
    TIWDBAdvWebGrid1: TTIWDBAdvWebGrid;
    FrameTopFrame1: TFrameTopFrame;
    FrameLeftFrame1: TFrameLeftFrame;
    ADOConnection1: TADOConnection;
    ADOQuery1: TADOQuery;
    IWListbox1: TIWListbox;
    DataSource1: TDataSource;
    procedure IWButton1Click(Sender: TObject);
    procedure IWAppFormCreate(Sender: TObject);
  public
  end;

implementation

{$R *.dfm}

uses
  ServerController;


procedure TformGridRowSelection.IWAppFormCreate(Sender: TObject);
begin
  ADOConnection1.ConnectionString :=
    'Provider=Microsoft.Jet.OLEDB.4.0;Password="";Persist Security Info=True;Data Source= ' +
  WebApplication.ApplicationPath + 'demos.mdb';
  DataSource1.DataSet.Active := true;
end;

procedure TformGridRowSelection.IWButton1Click(Sender: TObject);
var
  i{,numdel}: Integer;
begin
//  numdel := 0;
  IWListbox1.Items.Clear;

  for i := 1 to TIWDBAdvWebgrid1.RowCount do
  begin
    if TIWDBAdvWebGrid1.RowSelect[TIWDBAdvWebGrid1.RowOffset + i - 1] then
    begin
    {
      Table1.First;
      Table1.MoveBy(TIWDBAdvWebGrid1.RowOffset + i - 1 - numdel);
      Table1.Delete;
      }
      {
      DataSource1.DataSet.FindFirst;
      DataSource1.DataSet.MoveBy(TIWDBAdvWebGrid1.RowOffset + i - 1 - numdel);
      DataSource1.DataSet.Delete;
      }

      IWListbox1.Items.Add(IntToStr(i) + ' : ' + TIWDBAdvWebGrid1.CellValues[2,i-1] + ' : ' + TIWDBAdvWebGrid1.CellValues[3,i-1]);

      //Inc(numdel);
    end;
  end;
end;

initialization
  TformGridRowSelection.SetAsMainForm

end.
