Solved

should be easy vb question

Posted on 2003-10-24
4
155 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now