Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bound combobox selects invalid value
Message
From
13/05/2007 09:20:36
 
 
To
All
General information
Forum:
ASP.NET
Category:
Forms
Title:
Bound combobox selects invalid value
Miscellaneous
Thread ID:
01225058
Message ID:
01225058
Views:
73
To reproduce:
1. Run code. Select upper
2. press Tab

Observed:
combobox contains lower

Expected:

should contain upper

How to fix ?

using System.Windows.Forms;
using System.Data;
class testForm : Form {
ComboBox comboBox1;

testForm() {
DataTable t = new DataTable();
t.Columns.Add("displaymember");
t.Columns.Add("valuemember");
t.Rows.Add("lower", "a");
t.Rows.Add("upper", "A");

comboBox1 = new ComboBox();
comboBox1.DisplayMember = "displaymember";
comboBox1.ValueMember = "valuemember";
comboBox1.DataSource = t;
comboBox1.DataBindings.Add("SelectedValue", new bo(), "controlsrc");
TextBox tb = new TextBox();
tb.Top = 100;
Controls.AddRange(new Control[] { comboBox1, tb });
}

class bo {
string t;
public string controlsrc {
get { return t; }
set { t = value; }
}
}

static void Main() {
Application.Run(new testForm());
}
}
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform