我收到一条错误消息“无法将类型为'System.Data.DataViewManagerListItemTypeDescriptor'的对象转换为类型为'System.Data.DataRowView'". [英] I got an error message "Unable to cast object of type 'System.Data.DataViewManagerListItemTypeDescriptor' to type 'System.Data.DataRowView".
本文介绍了我收到一条错误消息“无法将类型为'System.Data.DataViewManagerListItemTypeDescriptor'的对象转换为类型为'System.Data.DataRowView'".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
先生,我在内部for-each循环中收到错误消息.
Sir i got error message in inner for-each loop.
private void buttonSelectAllAvailableStops_Click(object sender, EventArgs e)
{
bool found = false;
foreach (DataRowView drv1 in listBoxAvailableStops.Items)
{
foreach (DataRowView drv2 in listBoxSelectedStops.Items)
{
if (drv1.Row.ItemArray[0].ToString().Equals(drv2.Row.ItemArray[0].ToString()))
{
found = true;
break;
}
}
if (!found)
{
DataSet dt = ((System.Data.DataSet)(((System.Windows.Forms.BindingSource)listBoxSelectedStops.DataSource)).DataSource);
object[] oldRow = drv1.Row.ItemArray;
object[] newRow = new object[3];
newRow[0] = oldRow[0];
newRow[1] = oldRow[0];
newRow[2] = oldRow[1];
dt.Tables[0].Rows.Add(newRow);
listBoxSelectedStops.DataSource = dt;
}
found = false;
}
}
推荐答案
您尝试 ^ ]?
我认为以下链接会有所帮助.发布的代码一定有问题.
http://social.msdn.microsoft.com/论坛/en-US/winformsdatacontrols/thread/ea9a8516-3af7-49d0-9877-6a1ec705531f [ http://www.vbforums.com/showthread.php?t=553638 [ ^ ]
Did you try ^]?
I think following links would help. There must be something wrong out of the posted code.
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/ea9a8516-3af7-49d0-9877-6a1ec705531f[^]
http://www.vbforums.com/showthread.php?t=553638[^]
这篇关于我收到一条错误消息“无法将类型为'System.Data.DataViewManagerListItemTypeDescriptor'的对象转换为类型为'System.Data.DataRowView'".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文