Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ComboBox that has a DataSource set cannot be sorted.

Status
Not open for further replies.

kimprogrammer

Programmer
Sep 15, 2008
160
CA
Hello
I have my project that i have been working on for a bit - yesterday I added a new combobox in the designer and connected it to a bindingsources - everything looked ok and I finished for the day and saved my project. Today when I loaded my project I received the error "ComboBox that has a DataSource set cannot be sorted. Sort the data using the underlying data model." on the designer page and cannot see the screen. In the code I have the combo box being filled by a table adapter.

I did try a rebuild.

I've searched the site an got only one hit with this error - but they are doing something different so it was of no help.

If I set something up incorrectly(ie sort) in the properties page how do I fix it if I can't get to it. And I don't see what code I would change although I commented out the tableadapter. I did try changing the sql query I have for the file with the datasource (ie removed the order by)

Thanks for the help
 
When using a bound combobox, you should make sure the Sorted property of the combobox is False, and look at the BindingSource object for the combobox that is in your component section. This BindingSource object has a Sort property. Set this the same as you would in a SQL query, without the ORDER BY text.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Missed the part about the designer being messed up.

First to fix that, click the "Show All Files" button in your Solution Explorer. The form in question should have a FormName.Designer.vb file if you expand the + next to it. Open this file and fid the combobox in code in question. One of the lines should read ComboboxName.Sorted = True.

Change it to False or delete the line if changing does not work.) Save and reopen the designer form normally. That should fix the errant problem. You may also need to clean/rebuild the project before the designer window is fixed properly.

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Just as you said - although I seemed to need to exit out of visual studio and come back in.

Thanks so much
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top