可以这样实现,MouseToCell .... var Form1: TForm1; IsDrag:boolean; StringSource:string; implementation{$R *.DFM}procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer); var Column, Row: Longint; beginif ssleft in shift then begin StringGrid1.MouseToCell(X, Y, Column, Row); if not IsDrag then begin IsDrag:=true; StringSource:=StringGrid1.Cells[1,1]; end else StringGrid1.Cells[Column, Row]:=StringSource; end;end;procedure TForm1.FormCreate(Sender: TObject); begin IsDrag:=false; StringGrid1.Cells[1, 1]:='这里是要复制的内容'; end;procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); begin isdrag:=false; end;
....
var
Form1: TForm1;
IsDrag:boolean;
StringSource:string;
implementation{$R *.DFM}procedure TForm1.StringGrid1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
var
Column, Row: Longint;
beginif ssleft in shift then begin
StringGrid1.MouseToCell(X, Y, Column, Row);
if not IsDrag then begin
IsDrag:=true;
StringSource:=StringGrid1.Cells[1,1];
end
else
StringGrid1.Cells[Column, Row]:=StringSource;
end;end;procedure TForm1.FormCreate(Sender: TObject);
begin
IsDrag:=false;
StringGrid1.Cells[1, 1]:='这里是要复制的内容';
end;procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
isdrag:=false;
end;
stringgrid怎么没反应呀!!!