changing the behaviour of setting the DataSource property

P

progressdll

I'm trying to change the behaviour of setting the DataSource property
of combobox.

Here is the behaviour I now see.

Setting the DataSource property of combobox to an ArrayList will visual
display
the first value in the Text field of the combobox. ( or setting the
Text property ).

I don't want this to happen. Just load the DataSource, don't change the
Text property.

Any Ideas
 
S

Stephany Young

Bind the datasource in the normal way, set the Selected index to -1 THEN
subscribe the eventhandler to the SelectedIndexChanged event (or whichever
event you are using):

combobox.DataSource = MyDataSource;
combobox.DisplayMember = "aaa";
combobox.ValueMember = "aaa";
combobox.SelectedIndex = -1;
combobox.SelectedIndexChanged += new
EventHandler(combobox_SelectedIndexChanged);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top