Recent

Author Topic: DBGrid and CheckBox - reading the selected row ??????  (Read 2997 times)

abmservice

  • Jr. Member
  • **
  • Posts: 69
DBGrid and CheckBox - reading the selected row ??????
« on: January 02, 2012, 06:30:40 pm »
I have a DBGrid and CheckBox - it works but I can not read the selected rows to read the values ​​in other columns in this row and example, summed up, or deleted, updated.
Using Bookmarklist.
Code: [Select]
...
uses ..., dbgrids, stdctrls, ...
 
type
 
  { TForm1 }
 
  TForm1 = class(TForm)
  ...
    procedure DBGrid1CellClick(Column: TColumn);
    procedure DBGrid1UserCheckboxState(sender: TObject; column: TColumn; var AState: TCheckboxState);
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  ...
  private
    RecList: TBookmarklist;
  ...
  end;
 
procedure TForm1.DBGrid1CellClick(Column: TColumn);
begin
  if Column.Index=1 then
    RecList.CurrentRowSelected := not RecList.CurrentRowSelected;
end;
 
procedure TForm1.FormCreate(Sender: TObject);
begin
  RecList := TBookmarkList.Create(DbGrid1);
end;
 
procedure TForm1.FormDestroy(Sender: TObject);
begin
  RecList.Free;
end;
 
procedure TForm1.DBGrid1UserCheckboxState(sender: TObject; column: TColumn; var AState: TCheckboxState);
begin
  if RecList.CurrentRowSelected then
    AState := cbChecked
  else
    AState := cbUnchecked;
end;