點選DataGridView欄位取得欄位值

摘要:點選DataGridView欄位取得欄位值

1.

private void DataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
{
    //取得欄位值
    string value = DataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Value.ToString();
}

 

 

2.         Txt_Sample_Id.Text = dgvShowSample.CurrentRow.Cells[0].Value.ToString();
            lbeSample_Id.Text = dgvShowSample.CurrentRow.Cells[1].Value.ToString();