2012年12月2日 星期日

DataGridView Double Click 欄位填值


 Private Sub DataGridView1_CellDoubleClick(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellDoubleClick
        Select Case e.ColumnIndex
            Case 0
               TextBox1.Text = DataGridView1.CurrentRow.Cells(0).Value
            Case 3
                TextBox1.Text = DataGridView1.CurrentRow.Cells(3).Value
        End Select
    End Sub


Case 0 代表第一欄,

CurrentRow 就是 Double Click 的那一列,

Cells(0).Value  第一個欄位的值。