掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
StringGridでカット・&ペーストするのには (ID:33791)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
ちょいと変更 //ClipBord to StringGrid procedure TForm2.Button1Click(Sender: TObject); var StringList: TStringList; X,Y,X2: Integer; S,S2: String; I,Col,Row,MaxCol: Integer; begin StringList := TStringList.Create; ClipBoard.Open; StringList.Text := ClipBoard.AsText; Y := 0; Row := StringGrid1.Row; MaxCol := StringGrid1.Col; while Y < StringList.Count do begin Col := StringGrid1.Col; S := StringList[Y]; X := 1; if S <> '' then begin while X <> 0 do begin X2 := PosEx(Char(9),S,X); if X2 = 0 then begin S2 := Copy(S,X,Length(S)); X := 0; end else begin S2 := Copy(S,X,X2-X); X := X2 + 1; end; StringGrid1.Cells[Col,Row] := S2; Inc(Col); if MaxCol < Col then MaxCol := Col; end end else begin for I := StringGrid1.Col to MaxCol-1 do begin StringGrid1.Cells[I,Row] := ''; end; end; Inc(Y); Inc(Row); end; ClipBoard.Close; StringList.Free; end; //StringGrid to ClipBoard procedure TForm2.Button2Click(Sender: TObject); var StringList: TStringList; X,Y: Integer; S: String; begin StringList := TStringList.Create; for Y:=StringGrid1.Selection.Top to StringGrid1.Selection.Bottom do begin S := ''; for X:=StringGrid1.Selection.Left to StringGrid1.Selection.Right do begin S := S + StringGrid1.Cells[X,Y]; if X <> StringGrid1.Selection.Right then S := S + Char(9); end; StringList.Add(S); end; ClipBoard.Open; ClipBoard.AsText := StringList.Text; ClipBoard.Close; StringList.Free; end;
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.