可以设一个动态数组:select_text 来存放所选内容,并在MouseUp事件里写
如下代码:
procedure Tadd_db_area_win.StringGridMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
li_left,li_right,li_top,li_bottom,li_loop:integer;
begin
li_left:=stringgrid1.selection.left;
li_right:=stringgrid1.Selection.Right;
li_top:=stringgrid.Selection.Top;
li_bottom:=stringgrid.Selection.Bottom;
if li_bottom-li_top>0 then
begin
setlength(selection_text,((li_bottom-li_top)+1));
for li_loop:=li_top to li_bottom do selection_text[li_loop-
li_top]:=stringgrid.Cells[**,li_loop];
end
else
begin
setlength(selection_text,1);
selection_text[0]:=stringgrid.Cells[**,li_top];
end;
end;