Hello,
I have two windows operating DataGridViews and am trying to add the contents of two columns from the first window into the second window. (only for the rows whose checkbox is selected)
I am currently able to copy either one of the two columns, but am struggling to get both at the same time, using this code below:
In the first window:
For i As Integer = 0 To DataGridView1.Rows.Count - 1
Dim row As DataGridViewRow = DataGridView1.Rows(i)
If row.Cells("DataGridViewCheckBoxColumn1").Value = True Then
frm.AddItem(row.Cells(1).Value)
If row.Cells("DataGridViewTextBoxColumn3").Value.ToString = "" Then
MsgBox("Please select a 'User Reference' for all selected parameters.")
Exit Sub
End If
End If
And then in the second window:
Public Sub AddItem(ByVal UserReference As Object)
DataGridView1.Rows.Add(UserReference, "This needs to query value", "Parameter Name")
End Sub
In this I have moved the User Reference Column - row.Cells(1)
but I am also trying to move the parameter column - which is row.Cells(2)
in the 3rd column in second window in the place of the constant "Parameter Name"
I have two windows operating DataGridViews and am trying to add the contents of two columns from the first window into the second window. (only for the rows whose checkbox is selected)
I am currently able to copy either one of the two columns, but am struggling to get both at the same time, using this code below:
In the first window:
For i As Integer = 0 To DataGridView1.Rows.Count - 1
Dim row As DataGridViewRow = DataGridView1.Rows(i)
If row.Cells("DataGridViewCheckBoxColumn1").Value = True Then
frm.AddItem(row.Cells(1).Value)
If row.Cells("DataGridViewTextBoxColumn3").Value.ToString = "" Then
MsgBox("Please select a 'User Reference' for all selected parameters.")
Exit Sub
End If
End If
And then in the second window:
Public Sub AddItem(ByVal UserReference As Object)
DataGridView1.Rows.Add(UserReference, "This needs to query value", "Parameter Name")
End Sub
In this I have moved the User Reference Column - row.Cells(1)
but I am also trying to move the parameter column - which is row.Cells(2)
in the 3rd column in second window in the place of the constant "Parameter Name"