在datagridview C#之间发送项目 [英] Sending items between datagridview C#
问题描述
我有一个包含4个项目的列表框(称为DGV1,DGV2,DGV3和DGV4)和4个数据网格视图(DGVmaim-(数据来源),DGV1,DGV2,DGV3和DGV4)
用户从第一个DGVmaim中选择一行,列表框中的第一个项目表示DGV3,我希望将DGVmain中选择的行发送到名为DGV3的数据网格视图中。
I have a listbox with 4 items (called DGV1, DGV2, DGV3 and DGV4), and 4 datagridviews (DGVmaim- (where the data will originate from), DGV1, DGV2, DGV3 and DGV4)
The user selects a row from the first DGVmaim, and the first item in the listbox says DGV3, I want the row selected in the DGVmain to be sent into that datagridview called DGV3.
foreach (DataRow dr in productionDataGridView.Rows)
{
if(this.listBox2.Items.Count > 0)
{
Waxing2.Rows.Add(dr.ItemArray);
}
}
这可能吗? - 我知道它没什么可以解决的,但我想确保它可能,因为我无法在网上找到很多
我尝试过:
Is this possible? - I know its not much to work off, but I want to ensure its possible as I cant find much online
What I have tried:
foreach (DataRow dr in DGVmain.Rows)
{
if(this.listBox2.Items.Count > 0)
{
DGV3.Rows.Add(dr.ItemArray);
}
}
推荐答案
我不会尝试在数据网格视图之间移动数据数据源中的修改。
例如,如果每个数据网格视图的数据来自数据表或绑定源,请添加/删除/编辑源中的行。数据网格视图然后反映刷新后数据源中的更改。
Instead of trying to move the data between the data grid views, I would make the modifications in their data source.
For example if the data for each data grid view is originating from a data table or a binding source, add/remove/edit the rows in the source. The data grid view then reflects the changes in the data source once refreshed.
这篇关于在datagridview C#之间发送项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!