Hi
I have a ComboBox (comboBox) which DataSource is null.
I set comboBox.DataSource = arrayList.
comboBox.DataSource didn't change !! It is still null.
Why? How can I populate it? Note I never touch comboBox.Items.
Any hint wellcome.
Thaks.
blah blah blah is here! blah blah » Close
1 answers
Something like this?
ArrayList menuItems = new ArrayList();
menuItems.Add("Option 1");
menuItems.Add("Option 2");
menuItems.Add("Option 3");
DropDownList1.DataSource = menuItems;
DropDownList1.DataBind();
answered 2 years ago by:
0
Or for windows form:
ArrayList menuItems = new ArrayList();
menuItems.Add("Option 1");
menuItems.Add("Option 2");
menuItems.Add("Option 3");
comboBox1.DataSource = menuItems;
answered 2 years ago by:
0
Is the DataBind() method not required for windows forms?
answered 2 years ago by:
0
nope.
answered 2 years ago by:
2309
To penceq:
Yes:
ArrayList menuItems = new ArrayList();
menuItems.Add("Option 1");
menuItems.Add("Option 2");
menuItems.Add("Option 3");
comboBox1.DataSource = menuItems;
I did this. And after this
(comboBox1.DataSource == null) is true :((
answered 2 years ago by:
0
One small note:
I do step into in disassembler. I get into ListControl.SetDataConnection() which sets DataSource, but before it ends, it set it back to null. I cannot image why and I cannot read the disassembler.
answered 2 years ago by:
0
Sorry, I can't offer you much help there. I'm pretty new at this.
answered 2 years ago by:
0
Hi guys.
I think I gave found it. If you have comboBox.Sorted set to true, you cannot set DataSource. It is nice, it is natural, it is clevet. I love those genious from Microsoft who have designed ListControl classes. It is pretty example how to NOT do it.
Cheers!
answered 2 years ago by:
0
This post was imported from csharpfriends, if you have a similiar question please ask it again.
All previous members have been migrated, hope you enjoy the new platform!