Copy and paste into a DataGridView cell (C#)(复制并粘贴到 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.
推荐答案
这实际上比你想象的要容易.
This is actually easier than you might expect.
在 DataGridView 中创建一个 CellDoubleClick 事件,并在其中放入如下代码:
Create a CellDoubleClick event in your DataGridView and in it put code like this:
private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e) {
dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = Clipboard.GetText();
}
这篇关于复制并粘贴到 DataGridView 单元格 (C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:复制并粘贴到 DataGridView 单元格 (C#)


基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01