How to set selected value from Combobox?

前端 未结 11 1948
梦谈多话
梦谈多话 2020-12-01 15:33

I use combobox in c# windows form. I bound the item list as below:

var employmentStatus = new BindingList>();

emplo         


        
相关标签:
11条回答
  • 2020-12-01 16:04

    I suspect something is not right when you are saving to the db. Do i understand your steps as:

    1. populate and bind
    2. user selects and item, hit and save.. then you save in the db
    3. now if you select another item it won't select?

    got more code, especially when saving? where in your code are initializing and populating the bindinglist

    0 讨论(0)
  • 2020-12-01 16:06

    In windows Appliation we use like this

     DDLChangeImpact.SelectedIndex = DDLChangeImpact.FindStringExact(ds.Tables[0].Rows[0]["tmchgimp"].ToString());
     DDLRequestType.SelectedIndex = DDLRequestType.FindStringExact(ds.Tables[0].Rows[0]["rmtype"].ToString());
    
    0 讨论(0)
  • 2020-12-01 16:07

    Try this:

    KeyValuePair<string, string> pair = (KeyValuePair<string,string>)this.ComboBox.SelectedItem;
    
    0 讨论(0)
  • 2020-12-01 16:10

    try this

    combobox.SelectedIndex = BindingSource.Item(9) where "9 = colum name 9 from table"
    
    0 讨论(0)
  • 2020-12-01 16:10

    To set value in the ComboBox

    cmbEmployeeStatus.Text="Something";
    
    0 讨论(0)
  • 2020-12-01 16:15
    cmbEmployeeStatus.Text = "text"
    
    0 讨论(0)
提交回复
热议问题