954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Pass selected row in Datagrid view to another datagrid on another form

Hi, I am fairly a newbie to vb.net and am developing an inventory control windows application for a client.

I am creating a search form for my application. This search form searches the categorys table and returns the results in a datagrid view. The search bit of it is working, however what i want it to do next is not working!

I have a button on the Search form called "Return Data". Once the search results have been displayed in the datagrid view, the user will then select/highlight the row that they need. They will then click on the "Return Data" button and this button should then return the selected row in the datagrid view and display it in another datagrid view on another form.

I am just finding it extremely difficicult to getting this sorted. I have not got anywhere with it. Any sample code would be most appreciated.

Thanks

speedy gonzalos
Newbie Poster
11 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 
For Each r As DataGridViewRow In DataGridView1.SelectedRows
  MsgBox(r.Cells(0).Value)
Next
__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

Im not sure where to put the above code. Will it go in the onClick event of the Return Data button on the Search form?

speedy gonzalos
Newbie Poster
11 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Any where withing the form class where you want to copy selected rows.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You