Solved

should be easy vb question

Posted on 2003-10-24
4
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 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