Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 18th, 2005, 1:29 PM   #1
Arla
Professional Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 406
Rep Power: 4 Arla is on a distinguished road
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?
Arla is offline   Reply With Quote
Old Jul 18th, 2005, 1:36 PM   #2
Arla
Professional Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 406
Rep Power: 4 Arla is on a distinguished road
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?
Arla is offline   Reply With Quote
Old Jul 18th, 2005, 2:59 PM   #3
Arla
Professional Programmer
 
Arla's Avatar
 
Join Date: Mar 2005
Posts: 406
Rep Power: 4 Arla is on a distinguished road
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
Arla is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:26 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC