Advertisement

08.23.2008 at 08:52AM PDT, ID: 23672534 | Points: 500
[x]
Attachment Details

Copy cells from selected datagridview row to new row in other datagridview

Asked by wiswalld in Visual Basic Programming, Microsoft Visual Basic.Net

I have a contextmenustrip with some code behind one of the menu items (well thats what I want). I want to add a new row to datagridview2 and copy cell3, cell4 and cell5 from datagridview to the newly added row into cell 1, cell2 and cell0.

Datagridview2 with have some empty cells after the copy for the user to add there own data.

I started with

Me.BindingSource2.AddNew()

Then what. I tried

Me.BindingSource2.AddNew()
        For x As Byte = 0 To (DataGridView1.Rows.Count - 2)
            DataGridView2.Rows(x).Cells(0).Value = DataGridView1.CurrentRow.Cells(5).Value
        Next x

Just to try and copy one cell but no luck.Start Free Trial
[+][-]08.23.2008 at 02:16PM PDT, ID: 22298476

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628