c# - Getting text only from a specific column of DataGridView -


I have a datagroup view that is populated from 4 columns and several rows of data. I want to iterate through the DataGridView and want to get the cell value from a specific column , because I need to pass this data in a method.

Here is my code:

  foreach (DataDridViewRow in this line. DataGridView2.Rows) {foreach (DataGridViewCell cell in row.Cells) {if (cell.Value == null || cell.Value.Equals ("")) {Continue; } GetQuestions (cell.Value.ToString ()); }}  

It just starts to go through all the cells, although I should be able to specify something like this:

  foreach (in this DataGridViewRow Line.dataGridView2.Rows) {foreach (row column DataGridViewCell.Cells [2]) // Notified column index {if (cell.Value == zero) cell.Value.Equals ("")) {continue; } GetQuestions (cell.Value.ToString ()); }}  

Do you want to remove the internal foreach Loop? Or have I missed something?

  foreach (DataDridViewRow row in this .datagrid in View2.Rows) {DataGridViewCell cell = row.Cells [2]; // Note the specified column index if (cell.Value == faucet || Cells. Ecloss ("")) {continue; } GetQuestions (cell.Value.ToString ()); }  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -