Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

should be easy vb question

Posted on 2003-10-24
4
Medium Priority
?
163 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 75 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

926 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