Create new Thread for Private Sub DataGridView1_CellClick

  Uncategorised

Im trying to create a new thread for Private Sub, to make it run indepedently. Im unable to create a thread. Below is my code. Please suggest

Dim Thread_1 As System.Threading.Thread
Thread_1 = New System.Threading.Thread(AddressOf DataGridView1_CellClick)
Thread_1.Start()      

Private Sub DataGridView1_CellClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
    If e.ColumnIndex = 0 Then
        Me.DataGridView2.Rows.Add(DataGridView1.Rows(e.RowIndex).Cells(3).Value, "Co", "Speed", 75, DataGridView1.Rows(e.RowIndex).Cells(2).Value)
        'Script | PE/CE | LTP | Lots 
    End If

    If e.ColumnIndex = 1 Then 
        Me.DataGridView2.Rows.Add(DataGridView1.Rows(e.RowIndex).Cells(3).Value, "Co", "Mass", 75, DataGridView1.Rows(e.RowIndex).Cells(2).Value)
    End If

    If e.ColumnIndex = 5 Then
        Me.DataGridView2.Rows.Add(DataGridView1.Rows(e.RowIndex).Cells(3).Value, "Po", "Speed", 75, DataGridView1.Rows(e.RowIndex).Cells(4).Value)
    End If

    If e.ColumnIndex = 6 Then
        Me.DataGridView2.Rows.Add(DataGridView1.Rows(e.RowIndex).Cells(3).Value, "Po", "Mass", 75, DataGridView1.Rows(e.RowIndex).Cells(4).Value)
    End If

End Sub

Source: Visual Studio Questions

LEAVE A COMMENT