DataGridViews-将数据从一个DataGridView复制到另一个 [英] DataGridViews - Copy data from one DataGridView to another

查看:88
本文介绍了DataGridViews-将数据从一个DataGridView复制到另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有2个DataGridViews的表单-DataGridViewS和DataGridViewL.它们都具有相同数量的column(11),并且除了第一列之外,列标题也相同.我需要能够将选定的行从一个DataGridView复制到另一行而没有第一列,但其他列仍然对应.如果无法做到这一点,我将决定复制整个选定的行.我在对第一列进行排序时也遇到了问题.它的数据是数字(毫秒),当我对列进行排序时,其值1113低于11130.顺序(升/降)是正确的,因此我在确定它是数据的格式.在将数据输入到DataGridView之前,我正在使用对数据的转换为Int32(毫秒).我是编程新手,这超出了我的知识,对您的帮助将不胜感激!

I have a form with 2 DataGridViews - DataGridViewS and DataGridViewL. They both have the same amount of columns(11) and the column headers are the same except for the first column(s). I need to be able to copy a selected row from one DataGridView to the other w/o the first column, but still have the other columns correspond. If this is not possible, I would settle for copying the entire selected row. I''m also having problems sorting the first column. It''s data is numbers(milliseconds) and when I sort the column, a value of 1113 is below 11130. The order(ascending/descending) is correct, so I''m figuring it''s the format of the data. I''m using convert to Int32 on the data(milliseconds) before it''s entered into the DataGridView. I''m new at programming and this is beyond my knowledge, any help would be greatly appreciated!

推荐答案

GridViews已绑定到数据源,因此您不必这样做''从您从数据源复制的网格中复制.您可以使用诸如rowindexchanged之类的事件来获取数据源中的当前行和索引,然后将其复制到另一个网格的数据源中.
The GridViews are bound to a datasource so you don''t copy from the grids you copy from the datasources. You can use an event, such as rowindexchanged, to get the current row and index in the datasource then copy to the other grid''s datasource.


这篇关于DataGridViews-将数据从一个DataGridView复制到另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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