Click here to Skip to main content
15,909,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
                }
}
Posted
Updated 27-Apr-18 18:48pm

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900