* * *

Author Topic: Multi Delete from a TRxDBGrid  (Read 752 times)

donnie

  • Jr. Member
  • **
  • Posts: 72
Multi Delete from a TRxDBGrid
« on: March 18, 2016, 03:39:56 pm »
Hi there,
I've got a TRxDBGrid(almost the same with DBGrid just has much more functions) connected to a datasource (which is connected to a tzquery.dataset). The TRxDBGrid Options allow me to have multi selection to rows(Options->dgMultiselect ->True). Can I have multi delete from this TRxDBGrid ? I have connected this TRxDBGrid  with a TDBnavigator and when I select more than one row and press the delete button(-) from navigator no multi delete happens.  It just deletes the first selected row. I don't want to use TDBnavigator  if possible. in order to delete only one row I use the following code:

Code: Pascal  [Select]
  1.  
  2.   index := FindColumnIndex(TRxDBGrid1  , 'NUM');//FindColumnIndex finds the index of the column NUM from the  TRxDBGrid1  
  3.   TRxDBGrid1.SelectedIndex := index;
  4.   deletednum:= TRxDBGrid1.Columns.Items[index].Field.Value;
  5.   if MessageDlg('Delete Number', 'Do you wish to Delete this NUM ?', mtConfirmation, [mbYes, mbNo], 0) = mrYes then
  6.   begin
  7.       DbModule.GeneralQuery.Close;
  8.       DbModule.GeneralQuery.Connection := DbModule.ZConnection1;
  9.       DbModule.GeneralQuery.SQL.Clear;
  10.       DbModule.GeneralQuery.SQL.Text := 'DELETE FROM TABLE WHERE NUM= ' + InttoStr(deletednum);
  11.       DbModule.GeneralQuery.ExecSQL;
  12.       TRxDBGrid1.DataSource.DataSet.Refresh;

Any help if possible :).
Thank you.
« Last Edit: March 18, 2016, 03:44:18 pm by nek »

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus