Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bound combobox selects invalid value
Message
From
13/05/2007 11:05:33
 
 
To
13/05/2007 09:20:36
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
01225058
Message ID:
01225070
Views:
20
Andrus,

That's because the DisplayMember of a ComboBox is apparently not case-sensitive. I've not had to program around that yet, so I don't have my own code to give you, but I found this on CodeProject and it looks promising:

http://www.codeproject.com/combobox/comboboxcs.asp

It looks like it's C++ code, but you can probably convert it. I haven't had the chance to try it myself yet.

~~Bonnie



>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());
>	}
>}
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Reply
Map
View

Click here to load this message in the networking platform