Hallo,
weiss jemand wie man eine Zelle eines TStringgrids mittels ‚Drag & Drop‘ in ein anderes TStringgrid zieht ?
Mein Versuch funktionierte nicht:
unit UDrag;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Grids;
type
TForm1 = class(TForm)
Grid1: TStringGrid;
Grid2: TStringGrid;
procedure Grid2DragDrop(Sender, Source: TObject; X, Y: Integer);
procedure Grid2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Grid2DragDrop(Sender, Source: TObject; X, Y: Integer);
var
CurrCol,CurrRow : Integer;
begin
if ((source is TStringgrid) and (Sender is TStringgrid)) then
with (Sender as TStringgrid) do
begin
MouseToCell(x,y,CurrCol,CurrRow);
Cells[CurrCol,CurrRow]:=inttostr((Sender as TStringgrid).Row);
end;
end;
procedure TForm1.Grid2DragOver(Sender, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Accept:=Source is tstringgrid;
end;
end.
Wie muss die Eigenschaft ‚DragMode‘ eingestellt sein ?
Im voraus vielen Dank für Eure Hilfe.
Chris