I have a datagridview that is populated with 4 columns and multiple rows of data. I want to iterate through the datagridview and get the cell value from A SPECIFIC COLUMN ONLY, since i need this data to pass into a method.
Here is my code:
foreach (DataGridViewRow row in this.dataGridView2.Rows)
{
foreach (DataGridViewCell cell in row.Cells)
{
if (cell.Value == null || cell.Value.Equals(""))
{
continue;
}
GetQuestions(cell.Value.ToString());
}
}
This just seems to go through all the cells however i need to be able to specify something like:
foreach (DataGridViewRow row in this.dataGridView2.Rows)
{
foreach (DataGridViewCell cell in row.Cells[2])//Note specified column index
{
if (cell.Value == null || cell.Value.Equals(""))
{
continue;
}
GetQuestions(cell.Value.ToString());
}
}