03-07-13, 03:12 PM
جرب هذا :
كود :
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Try
If DataGridView1.RowCount > 0 Then
If DataGridView1.SelectedRows.Count > 0 Then
Dim dgvr As DataGridViewRow = DataGridView1.SelectedRows(0)
With dgvr
Me.TextBox1.Text = GetCellsValue(dgvr.Cells(0))
Me.TextBox2.Text = GetCellsValue(dgvr.Cells(1))
Me.TextBox3.Text = GetCellsValue(dgvr.Cells(2))
End With
End If
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
End Try
End Sub
Private Function GetCellsValue(ByVal dgvCell As DataGridViewCell) As String
Try
If dgvCell.Value IsNot Nothing Then
Return dgvCell.Value
End If
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)
End Try
End Function
