Text of a specific Column of a GridView

1

How can I get the text of a cell of a column concrete in a GridView ?

I need the text of a celda in particular, modify it, and put it back in the same cell, but I do not know how to access the Text of each of the Cells of the column of GridView and so then modify the texts.

    
asked by Geraniego 19.04.2017 в 12:35
source

2 answers

2

Being dataGridView the (Name) of your DataGridView would be something like this:

String texto = dataGridView.Rows[numeroFila].Cells[numeroColumna].Value.ToString();
    
answered by 19.04.2017 в 13:04
2

This is the short way to answer @cnbandicoot

Get the value of a cell:

string valor = dataGridView[colIndex, rowIndex].Value.ToString();

To set the value of a cell:

dataGridView[colIndex, rowIndex].Value = valor;
    
answered by 19.04.2017 в 18:56