Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Bound combobox selects invalid value
Message
De
13/05/2007 09:20:36
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Titre:
Bound combobox selects invalid value
Divers
Thread ID:
01225058
Message ID:
01225058
Vues:
80
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform