One way to do this would be to use the SelectedRows property of the DataGridView and when it is double clicked you could pass this to your next form. For example, if I had two Forms (Form1 and Form2) and Form1 contained a DataGridView I could set it up so that when the DataGridView is double clicked and one or more rows was selected I could pass these to Form2 via a property.
So, on Form2 you could have the following property:
Public Property SelectedRows As DataGridViewSelectedRowCollection
This would appear just below the Public Class Form2 line.
Then in Form1, for the DoubleClick event of the DataGridView you could do the following:
Private Sub DataGridView1_DoubleClick(sender As Object, e As EventArgs) Handles DataGridView1.DoubleClick
If DataGridView1.SelectedRows.Count > 0 Then
Dim newForm As New Form2
newForm.SelectedRows = DataGridView1.SelectedRows
Then to read from the SelectedRows property on Form2 you could use code similar too:
Which will return the value of the first row, second column.
I have two forms. i already have some values has been displayed in datagrid view in one form including name. In another form, i additionally add some more values including name field. I need to pass the second form values to the datagrid which was in first form by comparing name fields.
I have tried the following code example above to my project without any success can someone please help.
Here is a copy of my code
On the schedule_frm i declared: Public Property SelectRows As DataGridViewSelectedRowCollection
under the Public Class Schedule_Frm form class
Public Class Main_Frm
Private Sub TBL_TEAMSBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles TBL_TEAMSBindingNavigatorSaveItem.Click
Private Sub Main_Frm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'FootBallDataSet.TBL_TEAMS' table. You can move, or remove it, as needed.
Private Sub TBL_TEAMSDataGridView_Click(sender As Object, e As EventArgs) Handles TBL_TEAMSDataGridView.Click
If TBL_TEAMSDataGridView.SelectedRows.Count Then
Dim Schedule_Form As New Schedule_Frm
Schedule_Form.SelectRows = TBL_TEAMSDataGridView.SelectedRows
I Developed application in C# with crystal reports and created setup file in third party (Advance) Installer.When i installed my application on client system application is working but ...