复制并粘贴到一个DataGridView细胞(C#) [英] Copy and paste into a DataGridView cell (C#)

查看:146
本文介绍了复制并粘贴到一个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#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆