Inserting text gives objectcollection error

后端 未结 4 1983
终归单人心
终归单人心 2021-01-29 01:10

I want to insert each row in SQL into combobox, where EmployeeID will be combobox Value, and EmployeeFirstName EmployeeLastName will be text of combobox item. However this line<

4条回答
  •  时光取名叫无心
    2021-01-29 02:10

    Items.Insert is looking for you to Insert at a specific point in the ComboBox list.

    You want to use Items.Add

    comboBox1.Items.Add(dr.GetString(1) + dr.GetString(2) + dr.GetInt32(0));
    

    If you want to use Insert it would need to be something like this:

    comboBox1.Items.Insert(0, dr.GetString(1) + dr.GetString(2) + dr.GetInt32(0));
    

提交回复
热议问题