TStringGrid多选的复制与拷贝
uses Clipbrd;
function StringGridSelectText(mStringGrid: TStringGrid): string;
var
I, J: Integer;
S: string;
begin
Result := '';
if not Assigned(mStringGrid) then Exit;
for J := mStringGrid.Selection.Top to mStringGrid.Selection.Bottom do
begin
S := '';
for I := mStringGrid.Selection.Left to mStringGrid.Selection.Right do
S := S + #9 + mStringGrid.Cells[I, J];
Delete(S, 1, 1);
Result := Result + S + #13#10;
end;
end; { StringGridSelectText }
procedure StringGridPasteFromClipboard(mStringGrid: TStringGrid);
var
vTextList: TStringList;
vLineList: TStringList;
I, J: Integer;
begin
vTextList := TStringList.Create;
vLineList := TStringList.Create;
vLineList.Delimiter := #9;
try
vTextList.Text := Clipboard.AsText;
for J := 0 to vTextList.Count - 1 do
begin
if J + mStringGrid.Row >= mStringGrid.RowCount then Break;
vLineList.DelimitedText := vTextList[J];
for I := 0 to vLineList.Count - 1 do
begin
if I + mStringGrid.Col >= mStringGrid.ColCount then Break;
mStringGrid.Cells[I + mStringGrid.Col, J + mStringGrid.Row] := vLineList[I];
end;
end;
finally
vTextList.Free;
vLineList.Free;
end;
end; { StringGridPasteFromClipboard }
procedure StringGridCopyToClipboard(mStringGrid: TStringGrid);
begin
Clipboard.AsText := StringGridSelectText(mStringGrid);
end; { StringGridCopyToClipboard }
procedure TForm1.MenuItemCopyClick(Sender: TObject);
begin
StringGridCopyToClipboard(StringGrid1);
end;
procedure TForm1.MenuItemPasteClick(Sender: TObject);
begin
StringGridPasteFromClipboard(StringGrid1);
end;
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if ssCtrl in Shift then
case Key of
Ord('C'): StringGridCopyToClipboard(TStringGrid(Sender));
Ord('V'): StringGridPasteFromClipboard(TStringGrid(Sender));
end;
end;
http://blog.csdn.net/zswang/article/details/111607
TStringGrid多选的复制与拷贝的更多相关文章
- HTML,JS禁止鼠标右键、禁止全选、复制、粘贴的方法
禁止鼠标右键.禁止全选.复制.粘贴: oncontextmenu事件禁用右键菜单: js代码: document.oncontextmenu = function(){ event.returnVal ...
- JS禁用浏览器退格键、禁止右键、禁止全选、复制、粘贴
一.禁用浏览器退格键 摘抄自:https://www.cnblogs.com/wanggd/p/3164536.html 我们在真实的项目开发中经常会使用JS 对键盘上的一些按键进行禁用,常见的比如说 ...
- Qt之密码框不可全选、复制、粘贴无右键菜单等
转载---> http://blog.sina.com.cn/s/blog_a6fb6cc90101artk.html 在做用户登录界面的时候,往往会用到密码框,则其中的一些功能也要求与普通的输 ...
- 《挑战30天C++入门极限》C++类对象的复制-拷贝构造函数
C++类对象的复制-拷贝构造函数 在学习这一章内容前我们已经学习过了类的构造函数和析构函数的相关知识,对于普通类型的对象来说,他们之间的复制是很简单的,例如: int a = 10; int ...
- Vim中如何全选并复制?
全部删除:按esc后,然后dG全部复制:按esc后,然后ggyG 全选高亮显示:按esc后,然后ggvG(这个好像有点问题)或者ggVG正确 vim如何与剪贴板交互(将vim的内容复制出来) 习惯了在 ...
- C++复制(拷贝)构造函数详解
本文转载自 http://blog.csdn.net/lwbeyond/article/details/6202256,在此感谢作者 CTemp B(A); //复制构造函数,C++风格的 ...
- selenium中的对文本进行全选,复制,粘贴,剪切和删除的操作
# 键盘全选操作from selenium.webdriver.common.keys import Keysdriver.find_element_by_css_selector('#key-dem ...
- Javascript 对象复制(深浅拷贝)
一.数据类型分类: 基本变量 引用类型 二.什么叫做指针指向 栈内存.堆内存.指针指向(如下红圈圈的斜线). 三.赋值.拷贝.引用区别? 赋值指一个变量赋予某个值,包含两种方式,一种是直接量,另一种, ...
- Effective C++ .12 复制对象-拷贝构造函数的编写
当我们自己编写拷贝构造函数时,编译器就不会为该类生成默认拷贝构造函数了,对于assignment operator也是如此. 1. 拷贝构造函数中记得调用父类的拷贝构造函数,或者相应复制过程 clas ...
随机推荐
- 亲测有效,解决Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2) ";
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/hjf161105/article/details/78850658 最近租了一个阿里云云翼服务器,趁 ...
- Vue中this的绑定
之前写过一篇文章 ES6与React中this完全解惑 其实Vue也是相同的道理.在Vue的官方文档中提到: 不要在选项属性或回调上使用箭头函数,比如 created: () => consol ...
- 【Codeforces Round #438 A】Bark to Unlock
[链接]h在这里写链接 [题意] 在这里写题意 [题解] 枚举它是在连接处,还是就是整个字符串就好. [错的次数] 0 [反思] 在这了写反思 [代码] #include <bits/stdc+ ...
- cordova使用cordova-plugin-baidumaplocation插件获取定位
原文:cordova使用cordova-plugin-baidumaplocation插件获取定位 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/m ...
- HDU 1143 Tri Tiling(递归)
意甲冠军:一些现有的1*2小盒子.求拼3*n多少个长方形的拼写. 思考: 因为它是一个递归式.肯定会遇到层的关系.仔细观察,研究发现,每层应设置2一层.(奇数层不能是矩形)而从显卡好最后一层的最后一战 ...
- urllib2使用总结
keywords: urllib2,BeautifulSoup,cookielib 题外话: 小弟是编程爱好者,各位看官轻拍. 最近在使用urllib2抓取网页内容,在学习的过程中也查阅了不少资料,并 ...
- ios-利用键盘通知处理键盘出现时遮挡控件问题
-(void)viewDidLoad { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; //注册键盘显示通知 ...
- springboot 使用日志
spring boot 默认使用日志打印到console 添加application.properties文件在src/main/resoures文件夹下 logging.file=my.log 将日 ...
- get与post一些特殊情况下
p=574"> 文章已经迁移至http://androiddevelop.cn/?p=574 版权声明:本文博客原创文章.博客,未经同意,不得转载.
- 最简单的IdentityServer实现——IdentityServer
1.新建项目 新建ASP .Net Core项目IdentityServer.EasyDemo.IdentityServer,选择.net core 2.0 1 2 引用IdentitySer ...