[英]InvalidArgument=Value of '5' is not valid for 'SelectedIndex'
I read saved data from tbl in a list, and i want to edit the object, so when i start the program, combobox first to show saved value for that object, and others also to be in the combobox. 我从列表中的tbl中读取了保存的数据,并且我想编辑该对象,因此,当我启动该程序时,组合框首先显示该对象的保存值,其他组合也将出现在组合框中。 Please help !
请帮忙 !
if (lstP.Count > 0)
{
for (int i = 0; i < lstP.Count; i++)
{
if (Stav.IDP == lstP[i].SP)
{
Prim.SelectedIndex = lstP[i].SP;
//ERROR
break;
}
}
}
SelectedIndex requires a number to be passed. SelectedIndex需要传递一个数字。 What you need is to assign an
i
to it: 您需要为它分配一个
i
:
if (lstP.Count > 0)
{
for (int i = 0; i < lstP.Count; i++)
{
if (Stav.IDP == lstP[i].SP)
{
Prim.SelectedIndex = i;
break;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.