In this article I will explain with an example, how to pass (send) selected DataGridView Row from one Form to another in Windows Forms (WinForms) Application using C# and VB.Net.
When the DataGridView Row is clicked, the selected Row values of the DataGridView are passed (sent) to the other Form in Windows Forms (WinForms) Application using C# and VB.Net.
 
 
Form Design
Form1
The Form1 consists of a DataGridView which has been assigned CellMouseClick event handler.
Pass (Send) selected DataGridView Row from one Form to another using C# and VB.Net
 
Form2
The Form1 consists of three Labels.
Pass (Send) selected DataGridView Row from one Form to another using C# and VB.Net
 
 
Namespaces
You will need to import the following namespace.

C#
using System.Data;
 
VB.Net
Imports System.Data
 
 
Populating the DataGridView
Inside the Form Load event handler, the DataGridView is populated with data by making use of a dynamic DataTable with some records.

C#
private void Form1_Load(object sender, EventArgs e)
{
    DataTable dt = new DataTable();
    dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
                        new DataColumn("Name", typeof(string)),
                        new DataColumn("Country",typeof(string)) });
    dt.Rows.Add(1, "John Hammond", "United States");
    dt.Rows.Add(2, "Mudassar Khan", "India");
    dt.Rows.Add(3, "Suzanne Mathews", "France");
    dt.Rows.Add(4, "Robert Schidner", "Russia");
    this.dataGridView1.DataSource = dt;
    this.dataGridView1.AllowUserToAddRows = false;
}
 
VB.Net
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim dt As New DataTable()
    dt.Columns.AddRange(New DataColumn() {New DataColumn("Id", GetType(Integer)), _
                                           New DataColumn("Name", GetType(String)), _
                                           New DataColumn("Country", GetType(String))})
    dt.Rows.Add(1, "John Hammond", "United States")
    dt.Rows.Add(2, "Mudassar Khan", "India")
    dt.Rows.Add(3, "Suzanne Mathews", "France")
    dt.Rows.Add(4, "Robert Schidner", "Russia")
    Me.dataGridView1.DataSource = dt
    Me.dataGridView1.AllowUserToAddRows = False
End Sub
 
 
Passing (Sending) selected DataGridView Row from one Form to another
When the DataGridView Row or Cell is clicked, the Row Index of the clicked DataGridView Row is determined and the selected DataGridView Row is assigned to the SelectedRow property.

C#
public static DataGridViewRow SelectedRow { get; set; }
private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
    if (e.RowIndex >= 0)
    {
        //Set the Selected Row in Property.
        SelectedRow = dataGridView1.Rows[e.RowIndex];
 
        //Open the other Form.
        Form2 form2 = new Form2();
        form2.Show();
    }
}
 
VB.Net
Public Shared Property SelectedRow As DataGridViewRow
Private Sub dataGridView1_CellMouseClick(sender As System.Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dataGridView1.CellMouseClick
    If e.RowIndex >= 0 Then
        'Set the Selected Row in Property.
        SelectedRow = dataGridView1.Rows(e.RowIndex)
 
        'Open the other Form.
        Dim form2 As Form2 = New Form2
        form2.ShowDialog()
    End If
End Sub
 
 
Displaying the DataGridView Selected Row values on another Form
Inside the Form Load event handler, the selected DataGridView Row Cell values are extracted and displayed in Labels in Windows Forms (WinForms) Application using C# and VB.Net.
C#
private void Form2_Load(object sender, EventArgs e)
{
    lblID.Text = Form1.SelectedRow.Cells[0].Value.ToString();
    lblName.Text = Form1.SelectedRow.Cells[1].Value.ToString();
    lblCountry.Text = Form1.SelectedRow.Cells[2].Value.ToString();
}
 
VB.Net
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    lblID.Text = Form1.SelectedRow.Cells(0).Value.ToString()
    lblName.Text = Form1.SelectedRow.Cells(1).Value.ToString()
    lblCountry.Text = Form1.SelectedRow.Cells(2).Value.ToString()
End Sub
 
 
Screenshot
Pass (Send) selected DataGridView Row from one Form to another using C# and VB.Net
 
 
Downloads