Drag a row from a TDBGrid to a TMemo (Views: 30)
Problem/Question/Abstract: I have a TDBGrid with several rows of data in it. Is it possible to be able to drag one of the rows off of the grid and drop it on another control? Answer: procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); begin if DragDetect(DBGrid1.Handle, Point(x, y)) then DBGrid1.BeginDrag(False); end; procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := Source = DBGrid1; end; procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer); var i: Integer; begin Memo1.Clear; for i := 0 to DBGrid1.Columns.Count - 1 do Memo1.Lines.Add(DBGrid1.Columns[i].Field.AsString); {or use DataSet} end; |