Solved

should be easy vb question

Posted on 2003-10-24
4
156 Views
Last Modified: 2010-05-03
I'm displaying some data in a listbox named lstStatusOfTrans.  also on the form i am allowing the user to choose the way that the data is sorted.  i need a way to turn the sorted property of the list box on and off inside the code.  i thought i could use lstStatusOfTrans.Sorted = False but i would get a "Can't assign to read-only property" error message.  this has to be possible.  just wondering how i pull it off.  thanks.

Kris
0
Comment
Question by:kris-mayco
4 Comments
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 25 total points
ID: 9616152
>>this has to be possible. <<
Nope.  Not with the ListBox.  One workaround is to have two Listboxes and hide one as appropriate.

Anthony
0
 
LVL 42

Expert Comment

by:frodoman
ID: 9616212
If the contents of the box aren't huge, Anthony's suggestion (^^^^) will work well.

Another option is to set the sort property to 'false' at design time, then sort the contents before you load them into the listbox (I'm assuming you're loading from a db?).  

If the user wants to change the sortability of the box you would then have to delete the current contents are reload w/out sorting first.
0
 
LVL 15

Expert Comment

by:SRigney
ID: 9616354
Another option is to use a listview.  If you put the listview in Report mode and do not show the header column then it will appear the same as  the listbox.  The benefit is that it's sorted property can be changed at run-time.  The sort order can also be changed from Ascending to Descending.
0
 

Author Comment

by:kris-mayco
ID: 9616711
all good answers, thanks a lot, going to use the second list box, that looks like it will fit  the easiest into what i've got already.  
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question