ComboBox WinForm中的更改索引问题 [英] Problem with change index in ComboBox WinForm
本文介绍了ComboBox WinForm中的更改索引问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在ComboBox WinForm中的更改索引有问题吗?是什么问题?
I have Problem with change index in ComboBox WinForm?what is problem?
//fill
ShopDataSetTableAdapters.CompanyTableAdapter ComTa = new ShopDataSetTableAdapters.CompanyTableAdapter();
ComTa.Fill(shopDataSet1.Company);
//manupalte
int newindex = 0;
foreach (var item in comboBox1.Items)
{
if ((((System.Data.DataRowView)(item)).Row).ItemArray[1].ToString()=="Nokia")
{
newindex= int.Parse((((System.Data.DataRowView)(item)).Row).ItemArray[0].ToString());
break;
}
}
comboBox1.ValueMember = newindex.ToString(); //raise error
推荐答案
我解决了我的问题
i solve my problem
ShopDataSetTableAdapters.CompanyTableAdapter ComTa = new ShopDataSetTableAdapters.CompanyTableAdapter();
ComTa.Fill(shopDataSet1.Company);
//manipulate
object newitem = null;
foreach (var item in comboBox1.Items)
{
if ((((System.Data.DataRowView)(item)).Row).ItemArray[1].ToString()=="Nokia")
{
// newindex= int.Parse((((System.Data.DataRowView)(item)).Row).ItemArray[0].ToString());
newitem=item;
break;
}
}
comboBox1.SelectedItem = newitem;
这篇关于ComboBox WinForm中的更改索引问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文