Thank You
Joao
On start drag, save the key of the dragged item in some global. Then,
something like (untested)
Procedure tForm1.DBGridDragDrop(Sender, Source : TObject; X, Y : Integer);
var gc : TGridCoord;
NewKey : Integer;
begin
gc := DBGrid.MouseCoord(x, y);
If (gc.y > 0) and (gc.x > 0) then
begin
DataSet.MoveBy(gc.y - DBGrid.Row);
// you are now positioned in the dataset where you want to insert the new
record. Figure out the new key
Dataset.DisableControls;
DataSet.Locate('Key', Dragged, []);
DataSet.Edit;
DataSet.FieldByName('key').AsInteger := NewKey;
DataSet.Post;
DataSet.Enablecontrols;
end;
DBGrid.SetFocus;
end;
Robert