Get data from a DataGridView

0

How can I get data from a DataGridView? I have an object called dgvPersonas of type DataGridView, I charge data, they are shown correctly in the table and now I want to recover that data. Specifically select a row, to then obtain a column from that row. Can somebody help me?

    
asked by Pedro Rout 08.09.2017 в 01:42
source

2 answers

0

To get the value of the selected row just do this:

String Nombre = dgvPersonas .CurrentRow.Cells[0].Value.ToString(); 

//Cells[0] indica la coumna que quieres obtener el valor 
    
answered by 08.09.2017 / 14:03
source
0

Basically:

DataGridView dgvPersonas = new DataGridView();

//Recorre las filas..
foreach (DataGridViewRow fila in dgvPersonas.Rows)
{
    //Accede a la columna que quieras, o las recorres todas con otro foreach...
    DataGridViewCell columna1 = fila.Cells[0];
}
    
answered by 08.09.2017 в 13:59