Combobox databinding showing system.data.datarowview

后端 未结 7 1542
猫巷女王i
猫巷女王i 2021-01-01 00:08

I am binding combobox with datasource, displaymember, valuemember. It is working fine in my computer but it is not working in clients pc. Following is my source code:

<
7条回答
  •  迷失自我
    2021-01-01 00:09

    This definitely happens if your cbxMetal_SelectedIndexChanged is called before cbxAlloyBinding() is called in your constructor.

    For instance (see the code below), you may have other combobox bindings in constructor which may come before cbxAlloyBinding() in constructor, and those bindings are calling cbxMetal_SelectedIndexChanged.

    public Constructor()
    {
            InitializeComponent();
    
            cbxheatBinding();      //1st Three Binding Methods may be somehow related to your cbxMetal,
            dtpStartDateBinding(); //which leads them to call cbxMetal_SelectedIndexChanged method.
            dtpEndDateBinding();
            cbxAlloyBinding();
    }
    

    What I suspect is your cbxMetal.DataSource is set from some other point in your code and well before DisplayMember and ValueMember are assigned;

    Just remember, System.DataRow.DataRowView will occur only if

    ComboBox.SelectedValue is called before ValueMember assignment.

提交回复
热议问题