use of combobox ValueMember and DisplayMember

前端 未结 1 1678
别跟我提以往
别跟我提以往 2020-12-18 17:31

I have an excel file which has two columns (1. Name and 2. Value) which I want to bind to a ComboBox.

When I set the DisplayMember to name it s

相关标签:
1条回答
  • 2020-12-18 17:31

    You can assign value for ValueMember of combo box.

    OleDbDataAdapter da = new OleDbDataAdapter("SELECT [name],[value] FROM [Sheet1$] where Component=1 ", strConn);
    comboBox1.DisplayMember = "name";
    comboBox1.ValueMember = "value";
    comboBox1.BindingContext = this.BindingContext;
    

    HTH.

    0 讨论(0)
提交回复
热议问题