Click here to Skip to main content
15,072,391 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have Problem with change index in ComboBox WinForm?what is problem?


C#
//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
Posted
Updated 1-Feb-12 22:37pm
v2
Comments
Rajesh Anuhya 2-Feb-12 4:37am
   
Edited: "Treat my content as plain text, not as HTML" disabled.

1 solution

i solve my problem

C#
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;
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900