.NET DataGrid 复制/粘贴
我在 C# 项目中有一个数据网格。 我想做的是从数据网格复制数据,然后粘贴到文件中。然后编辑内容并从剪贴板插入回数据网格。
我可以将数据从数据网格复制到剪贴板,但无法将文本从剪贴板插入/替换到数据网格中。
如何将剪贴板中的数据插入到数据网格中?
从数据网格复制并粘贴到文件中的示例数据:
> 0 base_hair00 Egyptian 0 2 2 2 2 1 _S_Hair000_Front_L _C_elf-f-hair000 0 Hair000_Bottom_S _C_elf-f-hair000 0 Hair000_Top_S _C_elf-f-hair000 0 - - 0 - - 0 - -
我试图在末尾插入到数据网格中
> 0 base_hair02 Egyptian2 0 2 2 2 2 1 _S_Hair000_Front_L _C_elf-f-hair000 0 Hair000_Bottom_S _C_elf-f-hair000 0 Hair000_Top_S _C_elf-f-hair000 0 - - 0 - - 0 - -
I have a datagrid in C# Project.
What I am trying to do is copy data from datagrid and then paste in file. Then edit content and insert back to datagrid from clipboard.
I can copy data from datagrid into clipboard but I can not insert/replace text from clipboard into datagrid.
How can I insert data from clipboard into datagrid?
Sample data copied from datagrid and pasted into the file:
> 0 base_hair00 Egyptian 0 2 2 2 2 1 _S_Hair000_Front_L _C_elf-f-hair000 0 Hair000_Bottom_S _C_elf-f-hair000 0 Hair000_Top_S _C_elf-f-hair000 0 - - 0 - - 0 - -
This I am trying to insert into datagrid at the end
> 0 base_hair02 Egyptian2 0 2 2 2 2 1 _S_Hair000_Front_L _C_elf-f-hair000 0 Hair000_Bottom_S _C_elf-f-hair000 0 Hair000_Top_S _C_elf-f-hair000 0 - - 0 - - 0 - -
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
添加“粘贴”函数或处理 KeyDown 事件以侦听粘贴操作,如下所示:
Add a "Paste" function or handle the KeyDown event to listen for a Paste action like this:
我花了一段时间进行挖掘,找到了问题的解决方案,请查看 DataGridView 中的全局复制和粘贴选项,在帖子底部附近有一个指向代码的链接 (倒数第二个)。
I spent a while digging around and found the solution to your problem, look Global Copy And Paste Option In DataGridView, there's a link in there to code near the bottom of the posting (second last one).