我想从 datagridview 的一列中读取数据。我的 datagridview 包含许多列,但我想读取所有单元格,但只能从一列中读取。我使用此代码阅读了所有专栏:
foreach (DataGridViewColumn col in dataGridView1.Columns)
col.Name.ToString();
但我想读取特定列中的所有单元格。
最佳答案
试试这个
string data = string.Empty;
int indexOfYourColumn = 0;
foreach (DataGridViewRow row in dataGridView1.Rows)
data = row.Cells[indexOfYourColumn].Value;
关于c# - 如何从datagridview的一列中读取数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14977697/