复制并粘贴到 DataGridView 单元格中 (C#)
我需要能够从一个应用程序复制一个或多个名称(使用普通复制命令),然后能够双击 DataGridView 中的文本单元格将数据粘贴到网格单元格中。关于如何实现这一目标有什么想法吗?我正在尝试最大程度地减少此功能的键盘使用。
I need to be able to copy a name or names from one application (using the normal copy commands) and then be able to double click the text cell in a DataGridView to paste the data into the grid cell. Any ideas on how to accomplish this? I am attempting to minimize keyboard use for this functionality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该将事件处理程序附加到单元格单击事件,并用
Clipboard.GetText()
中的数据替换单元格中的文本。You should attach an eventhandler to the cell clicked event and replace the text in the cell by the data in
Clipboard.GetText()
.我写这个是为了复制泛型:
I've written this to copy a generic:
这实际上比您想象的要容易。
在 DataGridView 中创建一个 CellDoubleClick 事件,并在其中放置如下代码:
This is actually easier than you might expect.
Create a CellDoubleClick event in your DataGridView and in it put code like this: