blah blah blah is here! blah blah » Close

up0down
link

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.

last answered 2 years ago

1 answers

up0down
link

Something like this?
ArrayList menuItems = new ArrayList();
menuItems.Add("Option 1");
menuItems.Add("Option 2");
menuItems.Add("Option 3");
DropDownList1.DataSource = menuItems;
DropDownList1.DataBind();

up0down
link

Or for windows form:
ArrayList menuItems = new ArrayList();
menuItems.Add("Option 1");
menuItems.Add("Option 2");
menuItems.Add("Option 3");
comboBox1.DataSource = menuItems;

up0down
link

Is the DataBind() method not required for windows forms?

up0down
link

nope.

up0down
link

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 :((

up0down
link

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.

up0down
link

Sorry, I can't offer you much help there. I'm pretty new at this.

up0down
link

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!

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!

Feedback