¿Cómo seleccionar un valor de WinForm DataGridView, para una columna específica, cuando se hace clic en cualquier parte de toda la fila?

I've got a simple WinForm app which has a DataGridView on it. When the user clicks -anywhere- along the row results, I'm hoping to retrieve the value of the first column (i'll hard code that) which happens to be the ID of that row.

Anyone have any suggestions to how I can do this?

Lets assume the ID of the gridview is DataGridView1 <-- Bonus points for using the autoegenerated Id's :P

preguntado el 28 de agosto de 11 a las 05:08

.. wow. curious to why this gets a downvote... -

1 Respuestas

private void DataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{

   var value= DataGridView1[ID_ColumnName.Index,e.RowIndex].Value
}

También puedes usar CellMouseClick event handler and use the same code.

I hope you know how to get the event handlers.

Respondido 28 ago 11, 10:08

Works great :) I used CellMouseClick and yeah, i know how to wire that up. Cheers! (I was looking for some ROW event .. not a cell event). - Pure.Krome

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.