struct itemEx { public object Value; public string Text; public itemEx(object value, string text) { this.Value = value; this.Text = text; } //重点是override ToString public override string ToString() { return Text; } } ………… //绑定 itemEx item1 = new itemEx(); item1.Text = dsTrDevice.Tables[0].Rows[i][0].ToString(); item1.Value = dsTrDevice.Tables[0].Rows[i][1]; ComboBox1.Items.Add(item1); //反转换 itemEx item = new itemEx(); item = (itemEx)(this.ComboBox1.SelectedItem); string strValue = item.Value.ToString().Trim();
转载于:https://www.cnblogs.com/highmayor/archive/2009/06/29/1513275.html