Hi,
I have searched alot but can only find info on moving entire rows bound between 2 datagrids, but noting on moving single cells. I have some code below that works ok from DGV to textboxes but not from DGV1 to DGV2.

Dim i As Integer
        i = DataGridView1.CurrentRow.Index
        Form3.DataGridView1.Item(1, i).Value = DataGridView1.Item(0, i).Value
        Form3.DataGridView1.Item(2, i).Value = DataGridView1.Item(2, i).Value

I am getting the error:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

I am only learning VB so im not sure where im going wrong. I did try changing the value to a string and then placing in the new DGV but same thing. Thanks for any help in advance!

Hi bestofB

You have to declare a binding source to make it happen. Binding source can be liked to Binding navigator, Data Grid View, etc .. using datasource property.

Add a binding Source to your form

Link the datasource to either your project data source, or any other..

For example, You has a list of obeject storing your project data as below

Public Class MemberInfo

Public sub new()
'----Your initialization of vairables
end sub

End Class

Dim p As new List(Of Object)

Link the objects of the class Memberinfo to your data source and link it to the bindingsource,

From that binding source access your datagridview. This is like linking a tree structure that is a binding source linked to different datagrid view for specific fields

Also when the selected data change

Use Bindingsource1.currentchanged as a trigger for your events related to datagridview.

Note that the public data used in your object holding class will be the column fields in your datagridview ....

Dynamically vary the datasource with your other object holder also.

Rgrds

Sam

Hi Sam,
Thanks for replying to my response. I will have a crack at what you have detailed above and come back if I have any further problems. Thanks again!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.