Datagridview内容(行)复制到另一个Datagridview [英] Datagridview Content (Rows) copy To Another Datagridview
问题描述
您好!我正在制作一个程序将员工转移到其他分支,因此我得到两个datagridview,首先是数据绑定,所有员工的列表来自数据库,我让我的firsdatagridview最后用于checkboxcolumns coloumns。
我想这样当我点击按钮传输时,检查的行将被转移到另一个或第二个datagridview,但是我无法开发这个,是的我为这个过程搜索了更多的时间代码,但是失败了。任何人都可以帮我解决这个问题..
先谢谢
使用 System.Collections.Generic;
使用 System.Data;
使用 System.Linq;
// DataTable dt_source;
// DataTable dt_destination;
// 选择行
var selectedRows = 来自 DataRow r dt_source.Rows
其中 r [ mustTransfer]。等于( true )
选择 r;
// 复制行
dt_destination = selectedRows.CopyToDataTable ();
// 删除旧行
foreach (DataRow row in selectedRows)
dt_source.Rows.Remove(row);
// 然后将目标datagridview数据绑定到目标数据表(dt_destination)。跨度>
Hello! I m making a program to transfer employee''s into other branch, therefore I get two datagridview, first for data binding and all employee''s list from database, I make my firsdatagridview last coloumns for checkboxcolumns.
I want to that When I m clicking on button transfer then checked rows will be transfer into another or second datagridview, But I m unable to developed this, yes I search more n more time code for this process, but failed. can anyone help me about this problems..
Thanks In Advance
using System.Collections.Generic; using System.Data; using System.Linq; //DataTable dt_source; //DataTable dt_destination; // Selects the rows var selectedRows = from DataRow r in dt_source.Rows where r["mustTransfer"].Equals(true) select r; // Copy the rows dt_destination = selectedRows.CopyToDataTable(); // Remove old rows foreach(DataRow row in selectedRows) dt_source.Rows.Remove(row); // Then you databind the destination datagridview to the destination datatable (dt_destination).
这篇关于Datagridview内容(行)复制到另一个Datagridview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!