ComboBox:将文本添加到第0个索引

时间:2017-10-19 07:55:58

标签: c# winforms desktop-application

我尝试将“选择选项”文本添加到ComboBox中的第0个索引,但它显示空白

public void BindDdlPartyAccount()
    {
        PartyAccount objDDlBind = new PartyAccount();
        List<PartyAccount> ListDdlParty = new List<PartyAccount>();
        ListDdlParty = objDDlBind.getDDlPartyDetails();
        objDDlBind.selectOption = "Select Option";
        objDDlBind.selectOptionId = 0;
        ListDdlParty.Insert(objDDlBind.selectOptionId, objDDlBind);
        ddlEditPartyAcc.DataSource = ListDdlParty;
        ddlEditPartyAcc.ValueMember = "PAId";
        ddlEditPartyAcc.DisplayMember = "name";
   }

enter image description here

1 个答案:

答案 0 :(得分:0)

您应该添加自定义对象类型

istDdlParty = objDDlBind.getDDlPartyDetails();
objDDlBind.name= "Select Option";