Author: Tomas Rutkauskas
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:
1 2 procedure TForm1.DBGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y:
3 Integer);
4 begin5 if DragDetect(DBGrid1.Handle, Point(x, y)) then6 DBGrid1.BeginDrag(False);
7 end;
8 9 procedure TForm1.Memo1DragOver(Sender, Source: TObject; X, Y: Integer;
10 State: TDragState; var Accept: Boolean);
11 begin12 Accept := Source = DBGrid1;
13 end;
14 15 procedure TForm1.Memo1DragDrop(Sender, Source: TObject; X, Y: Integer);
16 var17 i: Integer;
18 begin19 Memo1.Clear;
20 for i := 0 to DBGrid1.Columns.Count - 1 do21 Memo1.Lines.Add(DBGrid1.Columns[i].Field.AsString);
22 {or use DataSet}23 end;