![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Professional Programmer
Join Date: Mar 2005
Posts: 406
Rep Power: 4
![]() |
Issues with ComboBoxes and DataSources
Okay, not sure if anyone can help, but I figure I'll give it a try.
So I have a generic "List" function that sets up a datatable object with some data. In my main program I am defining two datatables, I run the list function, create a copy of the datatable that is created, run the list again (with different parameters) and then create a copy of that new datatable. The issue, trying to get this all to display. The first list returns 17 records, if I only do that list (and stop) I get a nice list of data using the .DataSource and .DisplayMember methods. If I then go on and do the second list, I get three records from that, but the first table only shows System.Data.DataRowView instead of the actual data? Here is some code to try to explain (call to function)SetupTable(A); Makes = ExampleTable.Copy(); ComboBox1.DataSource = Makes; ComboBox1.DisplayMember = "Description"; (if I stop here, this works fine); SetupTable(B); Models = ExampleTable.Copy(); (now with different data as I called SetupTable(B) not SetupTable(A)) ComboBox2.DataSource = Models; (this is the line that seems to cause ComboBox1 to forget what it's displaymember is?) ComboBox1.DisplayMember = "Description"; I tried adding in ComboBox2.DisplayMember = "Description"; again after the DataSource for ComboBox2 had been set, but that didn't seem to effect anything. Anyone have any ideas? |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Mar 2005
Posts: 406
Rep Power: 4
![]() |
As a side note, a way round it appears to be, use listBoxes, they work just fine, it just seems to be ComboBoxes that have a wierd issue?
|
|
|
|
|
|
#3 |
|
Professional Programmer
Join Date: Mar 2005
Posts: 406
Rep Power: 4
![]() |
Okay, I managed to get it to work, putting in ComboBox1.BeginUpdate and ComboBox1.EndUpdate around the code that puts items into the list seemed to fix it. Not entirely sure I like the solution, but heck it works
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|