By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,996 Members | 1,179 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,996 IT Pros & Developers. It's quick & easy.

weird but heavy problem with ComboBoxes and DataSource

P: n/a
Hello everyone!

I have some weird(?) problems, and I am not quite sure if there are due to
my errors or maybe a limitation in the .Net framework.

I have a ComboBox I need to fill with the content of an untyped DataSet.
This is to be done in the "DropDown" Event (since the dataset is empty at
program start).

If I go with this:

this.cmbBx_SelectProjekte.DataSource =
this.cmbBx_SelectProjekte.DisplayMember = "BV_Name";

and the "Sorted" Property set to true, the comboBox remains empty !?!?
If I change the "Sorted" property to false, it works, I get the content from
the DataSet.

But with three big problems:
First of all, in that instance that I open the dropdown section of the
comboBox, the first Item is selected. This must not happen, since a lot of
code gets executed in the "SelectedItemChanged" Event, which should only be
executed if the USER selected an item.
The second problem is, that the SelectedItems are typeof
Why? The content of my DataSet consists of strings, which I do get if I use
a for-loop to fill the ComboBox.
Even worse, before the first string from the dataset finally arrives in the
box, there are two System.Data.DataRow Strings(!!) getting written into the
ComboBox that I need to filter?!?!?

But the worst problem of all is, that I do need the content SORTED.

Now, one other solutions erases some of my problems, but creates weird new

If I fill my comboBox with this:

for(int i=0; i<ergoDB._ProjectsDS.Tables["Projekte"].Rows.Count; i++)
this.cmbBx_SelectProjekte.Items.Add(ergoDB._Projec tsDS.Tables["Projekte"].Rows[i].ItemArray[1]);

and "Sorted" = true, its all fine. I got the drowDown Section filled, no
item is selected until I do so explicitly and the items in the array are
typeof string.
So far so good, I should be happy here. Should I?

If I set Sorted to false, the comboBox gets filled with the following string:

Now here's why I can't go for the loop and Sorted = true:
In the end, the strings that fill the combobox need to consists of two
columns of my dataset (projectnumber and projectname appended).
Heres the catch: If an item is selected, I do need the ValueMember property,
since I must process the projectnumber differently from the rest.
So I can't go with the loop, which is the only one that so far fully works.

What the hell is going on here?
This is driving me crazy, I have so much other stuff to take care off...
Please, I need help quite desperatly...

Jul 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.