Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / April 2005

Tip: Looking for answers? Try searching our database.

ComboBoxes and the sorted property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ScottBH@online.nospam - 15 Oct 2004 00:01 GMT
Discovered a fun one that I thought I should share, and hopefully catch
Microsoft's attention to update some documentation.

I'm a bit new to VB.NET, and was struggling with getting a combo box to
work. I was attempting to take advantage of the cool way to load a combo box
via a datasource, rather than the old VB6 way of adding selections.

First I tried an array of objects. I had some issues with that that I
suspect had a lot to do with not overloading ToString on the class so the
combo box would return the right thing for the displaymember item. But I had
also read some bugs around arrays and combo boxes, so I switched to a
disconnected dataset.

I had a heck of a time getting the combo box to load properly. I kept
getting either no data in the combo box, or it kept showing the phrase
"System.Data.DataRowView". I found out that you have to set the datasource
property first, before you set the datamember and the valuemember properties.

But the real kicker was that you can't use the datasource and get it to work
if the sorted property on the combo box is set to true. It appears that if
you set that property to true, then the combo box assumes you're going to do
things the old VB6 way and use the Add items method to the combo box. My
tipoff something was wrong that I'd watch the debugger, and right after the
statement like this:

 cbTest.DataSource = dsInfo.Tables(0)

the value of cbTest.Datasource was "nothing", like the assignment didnt take.

In order to get things to work the way I wanted them to, I simply built a
dataview that sorted the table for me, and fed that to the combobox with the
sorted value off, and it finally worked. Three weeks later, of course.

Would someone from Microsoft confirm that you shouldn't use datasource in
combo and list boxes if you set the Sorted property to true in the form
designer? If that is the case, note that somewhere in the MSDN information
about the ListBox and the ComboBox classes!! It's not mentioned in the
MSPress books either (I have Programming Microsoft Visual Basic.Net, the 2003
version, ISBN 0-7356-2059-8)
Troy Gerton - 02 Nov 2004 21:03 GMT
Wow!  Thanks for this posting.
I am migrating a windows app from v1.0 to v1.1 and ran across this problem
which obviously did not exist with v1.0.  Thanks again...Troy

> Discovered a fun one that I thought I should share, and hopefully catch
> Microsoft's attention to update some documentation.
[quoted text clipped - 35 lines]
> MSPress books either (I have Programming Microsoft Visual Basic.Net, the 2003
> version, ISBN 0-7356-2059-8)
straightener - 07 Apr 2005 15:59 GMT
This bug is an embarassment to Microsoft and should be addressed in the next
version.  I just wasted 2 hours trying to get a DataTable to bind to a combo
box and luckily ran across this post.  Turns out that if you create a
strongly typed DataSet using the Component class container and use the
DataTable that resides inside, you do not have to use the DataView on the
DataTable.  Insconsistent and frustrating!!

Bret

> Wow!  Thanks for this posting.
> I am migrating a windows app from v1.0 to v1.1 and ran across this problem
[quoted text clipped - 39 lines]
> > MSPress books either (I have Programming Microsoft Visual Basic.Net, the 2003
> > version, ISBN 0-7356-2059-8)

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.