?
Solved

should be easy vb question

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Suggested Courses
Course of the Month13 days, 4 hours left to enroll

777 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