ComboBox Issue: Cannot bind to new value member

后端 未结 6 1635
甜味超标
甜味超标 2021-01-14 08:02

I\'v got a combobox that I created as a user control(it\'s actually made up of a label, combobox and textbox). I\'m trying to bind a dataset to the combobox datasource, but

6条回答
  •  旧巷少年郎
    2021-01-14 08:22

    I think you have the property Modifiers of your combo to something different from Public.
    However I will choose to implement two new public properties at the usercontrol level.
    DisplayMember and ValueMember just to avoid that ugly cast.
    In the set/get accessor I will reflect the values in/from the internal combo

    public string DisplayMember
    { 
        get { return combobox1.DisplayMember; } 
        set { combobox1.DisplayMember = value;} 
    } 
    public string ValueMember 
    { 
        get { return combobox1.ValueMember; } 
        set { combobox1.ValueMember = value;} 
    } 
    

提交回复
热议问题