我有一個DataGridView和一個TextBox。當我點擊DataGridView的單元格時,必須將該值複製到文本框中。但是這並不總是有效的:它只有時有效。textbox上datagridview的值
這裏是我的代碼:
private void gvProductos_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
//DataGridViewRow row = new DataGridViewRow();
//row = gvProductos.Rows[e.RowIndex];
////txtDescripcion.Text = string.Empty;
//txtDescripcion.Text = row.Cells[1].Value.ToString();
txtDescripcion.Text = gvProductos.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
}
你有沒有在你的小區的鏈路,/按鈕/ LinkButton的?你需要一個控制來觸發一個事件! – 2010-10-11 23:36:04
@ user459057:只有當您單擊單元格中其他任何位置的單元格的內容部分時,纔會觸發CellContentClick。 – JPReddy 2010-10-14 05:41:18