스트링그리드의 셀 내용을 클립보드에 복사하는 다양한 방법
uses Clipbrd;
...
(방법1) 외부 버튼
procedure TForm1.SpeedButton1Click(Sender: TObject);
var
S: string;
GRect: TGridRect;
C, R: Integer;
begin
GRect := sGrid.Selection;
S := '';
for R := GRect.Top to GRect.Bottom do
begin
for C := GRect.Left to GRect.Right do
begin
if C = GRect.Right then S := S + (sGrid.Cells[C, R])
else
S := S + sGrid.Cells[C, R] + #9;
end;
S := S + #13#10;
end;
ClipBoard.AsText := S;
end;
(방법2) OnKeyPress Ctrl+C
procedure TForm1.sGridKeyPress(Sender: TObject; var Key: Char);
begin
case Key of
#3: begin // Ctrl-C
// if not sGrid.EditorMode then
Clipboard.AsText := sGrid.Cells[sGrid.Col, sGrid.Row];
end;
end;
(방법3) 팝업메뉴
procedure TForm1.miCellCopyClick(Sender: TObject);
begin
Clipboard.AsText := sGrid.Cells[sGrid.Col, sGrid.Row];
end;
(참고) OnKeyPress 복사 및 붙여넣기
case Key of
#3: begin // Ctrl-C
if not sGrid.EditorMode then
Clipboard.AsText := sGrid.Cells[sGrid.Col, sGrid.Row];
end;
#22: begin // Ctrl-V
if not sGrid.EditorMode then
sGrid.Cells[sGrid.Col, sGrid.Row] := Clipboard.AsText;
end;
end;
'델파이' 카테고리의 다른 글
어플리케이션 윈도우 맨 앞에 나타내기 (0) | 2019.09.04 |
---|---|
윈도우10 1803 버전 업데이트후 델파이 2007 프로젝트 opening 에러 Borland.Delphi.Targets (0) | 2019.08.26 |
json 문자열 파싱(parsing) (0) | 2019.06.21 |
DBGrid 컬럼 Width 화면 크기에 따라 자동 변경하기 (0) | 2019.03.05 |
TMemo 모든 내용(행, Line) 보이게 세로 크기 늘리기 (0) | 2019.02.15 |