日期:2014-05-18  浏览次数:20508 次

combox已绑定,怎么通过ValueMember找到对应的哪项?求解
如题

------解决方案--------------------
写个demo给你
前台一个TextBox和一个ComBoBox
C# code

            DataTable data = new DataTable();
            data.Columns.Add("column1", typeof(int));
            data.Columns.Add("column2", typeof(string));
            DataRow dr1 = data.NewRow();
            dr1["column1"] = 1;
            dr1["column2"] = "NO.1";
            DataRow dr2 = data.NewRow();
            dr2["column1"] = 2;
            dr2["column2"] = "NO.2";
            DataRow dr3 = data.NewRow();
            dr3["column1"] = 3;
            dr3["column2"] = "NO.3";
            DataRow dr4 = data.NewRow(); 
            data.Rows.Add(dr1);
            data.Rows.Add(dr2);
            data.Rows.Add(dr3);
            this.comboBox1.DataSource = data;
            this.comboBox1.DisplayMember = "column2";
            this.comboBox1.ValueMember = "column2";