C# 循环通过组合框并与数据库中的数据进行比较
我尝试了几种方法来循环组合框,但它不起作用C# 循环通过组合框并与数据库中的数据进行比较,c#,winforms,loops,combobox,C#,Winforms,Loops,Combobox,我尝试了几种方法来循环组合框,但它不起作用 for (Int16 i = 0; cbxrecipe.Items.Count - 2 >= i; i++) { if (cbxrecipe(i).Items.ToString() != Reader_recipe1.GetValue(0).ToString())` { //update the combobox;
for (Int16 i = 0; cbxrecipe.Items.Count - 2 >= i; i++)
{
if (cbxrecipe(i).Items.ToString() != Reader_recipe1.GetValue(0).ToString())`
{
//update the combobox;
}
}
意味着我需要在组合框中循环,以检查组合框中的项目是否与数据库中的数据相同,如果相同,则不会更新,否则,组合框将立即显示新项目
感谢您的帮助=您的代码中有一个错误 试试这个:
for (Int16 i = 0; cbxrecipe.Items.Count - 2 >= i; i++)
{
if (cbxrecipe.Items[i].ToString() != Reader_recipe1.GetValue(0).ToString())
{
//update the combobox;
}
}