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#)


- WebMatrix WebSecurity PasswordSalt 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 输入按键事件处理程序 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01