【发布时间】:2015-05-21 10:10:04
【问题描述】:
我有以下代码:
foreach (DataGridViewRow row in dataGridView1.SelectedCells)
{
textBox1.Text += row.Cells[1].Value;
}
您可能会说我正在尝试根据 dataGridView 的选定行循环遍历特定列。但它在以下行给了我一个错误:
foreach (DataGridViewRow row in dataGridView1.SelectedCells)
错误是:
Additional information: Unable to cast object of type 'System.Windows.Forms.DataGridViewTextBoxCell' to type 'System.Windows.Forms.DataGridViewRow'.
【问题讨论】:
标签: c# visual-studio-2013 datagridview .net-3.5 c#-3.0