OK, so this one is a bit odd.
I have a pretty straightforward DataTable
:
DataTable dt = new DataTable();
dt.Columns.Add("Display", typeof(string));
dt.Columns.Add("Value", typeof(string));
dt.Rows.Add("Equals", "==");
dt.Rows.Add("Is Less Than", "<");
dt.Rows.Add("Is Less Than Or Equal To", "<=");
dt.Rows.Add("Is Greater Than", ">");
dt.Rows.Add("Is Greater Than Or Equal To", ">=");
Now, if I attach this DataTable
to a brand new ComboBox
, everything works as it should.
comboBox1.DataSource = dt;
comboBox1.ValueMember = "Value";
comboBox1.DisplayMember = "Display";
This control displays Equals
, Is Less Than
, etc.
In my form, however, I have another ComboBox
that is dynamically created, given a dynamic name based on which row in a TableLayoutPanel
it is in, etc.
When I use the exact same code for it, it displays System.Data.DataRowView
for each dropdown selection:
So, rather than me going through each line of code one by one and trying to reverse engineer this, can someone tell me what would cause this to happen? Is there some predictable and repeatable way to cause this behaviour? I've tried all of the following to reverse it but nothing works:
dtecComboAction.DataSource = null;
dtecComboAction.DataBindings.Clear();
dtecComboAction.Items.Clear();
dtecComboAction.BindingContext = this.BindingContext;
I'm sure I'm doing something obvious somewhere else in my code but I can't figure it out.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…