473,225 Members | 1,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

weird problem with filling comboboxes using DataSource/DisplayMemb

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 =
ergoDB._ProjectsDS.Tables["Projekte"];
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
System.Data.DataRowView.
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
ones:

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:
System.Data.DataViewManagerListItemTypeDescriptor
?!?!?!?!?!?

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
1 2053
To make it more clearly:

What I need in the end is:
* The comboBox filled with a sorted list.
* each item is a combination of two columns (projectNumber + projectName)
* the text-field of the comboBox empty as long as no item of the list has
been selected explicitly
* the ValueMember filled with the content of the projectnumber column

And the following needs to be inserted:
Before the for loop I set the DataSource to the DataSet (but not the column):
this.cmbBx_SelectProjekte.DataSource = ergoDB._ProjectsDS;
without this, the loop doesn't work...

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kaneda | last post by:
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...
0
by: Timothy White | last post by:
I have a Windows Form Which Displays one record at a time. The DataTable object which is bound to the Form Controls only contains the record that is being displayed. When I need to display a...
1
by: Keith Henderson | last post by:
I have a datatable that needs to be the datasource for 10 comboboxes. how do I do a for each for page_load to do this?
1
by: Adjo | last post by:
Okay, I've seen all the examples of using comboboxes on webforms when using simple values. And in the issue-tracker starterkit there is a way to use comboboxes with id/value foreign keys in a smart...
1
by: Kaneda | last post by:
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...
0
by: mjsterz | last post by:
I've been working with VB .NET for less than a year and this is the first time I've posted on one of these groups, so let me apologize beforehand if I'm being unclear, not posting my issue...
4
by: ECathell | last post by:
I am trying to databind 2 combo boxes to the same datasource but different fields using the same lookup table. The information in combobox2 is duplicating combobox 1(ie it appears to be gathering the...
2
by: Wingot | last post by:
Hey, I have a view to a database that I have created for Client Maintenance. It has a number of fields, but the important ones are Medical Condition, Bill To, and Country. I have a couple of...
1
by: Alex | last post by:
Hi, I have a strange question... I have a series of combo boxes being populated by the same dataset, and I've noticed if one is changed then all change as well. I'm using Visual Basic 2005 and...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.