日期:2014-05-17  浏览次数:21083 次

从xml文件读取值并绑定多个控件,控件互相干扰的问题 求助
大家好  我写了个函数用来从xml文件中读取控件的值,然后绑定。但是奇怪的是,当选择控件comboBoxEx41的值时, comboBoxEx42和comboBoxEx43 也同时变成和 comboBoxEx41 一样了。  请问是什么问题呢?
我想让三个控件绑定相同的属性值,操作互不干扰,应该怎么修改呢? 谢谢  下面是代码:


//从xml文件中绑定控件
            private void update1()
        {
            DataSet ds = new DataSet();            
            string fromPath = System.Environment.CurrentDirectory + @"\conf\rate_group.xml";
            FileInfo xmlFile = new FileInfo(fromPath);
            if (xmlFile.Exists)
            {
                FileStream fsReadxml = new FileStream(fromPath, FileMode.Open);
                XmlTextReader myXmlReader = new XmlTextReader(fsReadxml);
                ds.ReadXml(myXmlReader);                
                myXmlReader.Close();
            } 

            comboBoxEx41.DataSource = ds.Tables[0];
            comboBoxEx41.DisplayMember = "displaymember";
            comboBoxEx41.ValueMember = "valuemember";
            comboBoxEx41.SelectedIndex = -1;
            comboBoxEx41.DropDownStyle = ComboBoxStyle.DropDownList;


            comboBoxEx42.DataSource = ds.Tables[0];
            comboBoxEx42.DisplayMember = "displaymember";
            comboBoxEx42.ValueMember = "valuemember";
            comboBoxEx42.SelectedIndex = -1;
            comboBoxEx42.DropDownStyle = ComboBoxStyle.DropDownList;


            comboBoxEx43.DataSource = ds.Tables[0];
            comboBoxEx43.DisplayMember = "displaymember";
            comboBoxEx43.ValueMember = "valuemember";
            comboBoxEx43.SelectedIndex = -1;
            comboBoxEx43.DropDownStyle = ComboBoxStyle.DropDow