RadGrid中的循环

本文关键字:循环 RadGrid | 更新日期: 2023-09-27 18:30:07

我正在使用datatable检索值列表,并将其与windows窗体中的组合框控件绑定到RadGrid上。

问题:

  1. 我将如何检索数据表中的每个组合框值

这是我的代码:

foreach (DataGridViewRow row in RadGrid.Rows) //error here -- 'Telerik.WinControls.UI.GridViewRowInfo' to 'System.Windows.Forms.DataGridViewRow'
            {
                foreach (DataGridViewCell cell in row.Cells)
                {
                }
            }

RadGrid中的循环

我对Telerik网格一无所知,但从您显示的错误来看,它们的行似乎不是DataGridViewRow的,而是GridViewRowInfo。

像这样重写你的代码,看看它是否有帮助:

foreach (Telerik.WinControls.UI.GridViewRowInfo row in RadGrid.Rows)
{
    foreach (Telerik.WinControls.UI.GridViewCellInfo cell in row.Cells)        
    {
    }
}

请注意,它们对行和单元格使用自己的数据类型。您收到的错误是告诉您不能从WinForms网格类型转换为Telerik网格类型。有关详细信息,请参阅此文档。

这行吗??

comboBox1.Items.add(cell.Value.ToString());

如果您正在检索。。

cell.value = comboBox1.Items[cell.RowIndex];