Showing posts with label Binding. Show all posts
Showing posts with label Binding. Show all posts

Sunday, September 29, 2013

VB.Net ต้องการนำค่าที่อยู่ใน Row ปัจจุบัน ใน Datagridview ไปแสดงใน Label

Private Sub DataGridView_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) _ 
        Handles DataGridView.SelectionChanged
           With DataGridView1
             If .RowCount > 0 Then
                 If Not .CurrentRow.Cells("EMP_NO").Value Is DBNull.Value Then
                    Label1.Text = .CurrentRow.Cells("EMP_NO").Value
                 Else
                    Label1.Text = "-"
                 End If
              End If
            End With
End Sub

   

Private Sub DataGridView1_SelectionChanged(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles DataGridView1.SelectionChanged Dim row As DataGridViewRow = DataGridView1.CurrentRow TextBox1.Text = row.Cells(0).Value.ToString() TextBox2.Text = row.Cells(1).Value.ToString() TextBox3.Text = row.Cells(2).Value.ToString() End Sub