2 questions on possiblities with ListBox
I don't think you can in the first case, can you have the user being able to control Sorted/Unsorted. I know a day or two ago when I was thinking about it I got an error that made think you can only control Sorted at program time and not at runtime.
Also, is it possible to 'drag and drop" selections. I would like to be able to drag down the text with the mouse and have that act as the 'selection' when I hit the Enter key and have it move over to List2 or back to List1. In some cases I have a couple hundred entries and don't want any but those on the bottom of the list. It would make things a lot quicker if I could make a drag selection versus doing everything with the keyboard. I do have another idea but this one would be so much nicer.
Re: 2 questions on possiblities with ListBox
Both questions have "yes" answers with workarounds.
1) You cannot set the Sorted property during run-time. Therefore, to toggle from unsorted to sorted, you must either manually sort the items or clear the listbox & re-add them. Unsorted is not an issue. The listbox's .AddItem method allows you to dictate which position the new item will be inserted at. This overrides the sort behavior of the listbox
2) Try searching the forum for: listbox drag. You should find some examples
Re: 2 questions on possiblities with ListBox
Quote:
Originally Posted by
LaVolpe
Both questions have "yes" answers with workarounds.
1) You cannot set the Sorted property during run-time. Therefore, to toggle from unsorted to sorted, you must either manually sort the items or clear the listbox & re-add them. Unsorted is not an issue. The listbox's .AddItem method allows you to dictate which position the new item will be inserted at. This overrides the sort behavior of the listbox
2) Try searching the forum for: listbox drag. You should find some examples
You would still have to manually sort if you cleared the listbox & re-added them wouldn't you? I know right now whenever I update the listboxes I always do it through Clear and re-add, so that approach isn't a problem, but I would have to first get them sorted wouldn't I? If Sorted = False they would still come out unsorted.
Re: 2 questions on possiblities with ListBox
You got me backwards ;)
If the listbox has Sorted=True. Clearing & re-adding effectively re-sorts them. If you want to add new items to the end of a sorted listbox and prevent sorting, then you'd have to use the optional Index parameter of the .AddItem method
Code:
List2.AddItem "New Item", List2.ListCount
If the listbox has Sorted=False, you must always manually sort them.
Re: 2 questions on possiblities with ListBox
Okay, after typing back a nice reply thinking you didn't understand me I reread youy post again and it hit me. I went and tried it and it works. Now I get the picture. Where's the hammer to the head Smilie...I need it right now.
I'll do some research on the listbox/drag selection and drop and see what I come up with.
One down one to go.
Thanks.
Re: 2 questions on possiblities with ListBox
There's another way around the sorted/unsorted listbox problem and that is to have two listboxes exactly on top of each other, one sorted and the other not, and hide the one you don't need. This may or may not be a better solution but it is workable.
Re: 2 questions on possiblities with ListBox
It should work but LaVolpe idea is grand.
Code:
Private Sub Command11_Click()
List1.Clear
For i = 0 To eFileCounter
List1.AddItem eUser(i), List1.ListCount
Next
End Sub
I did this and it works like a charm. I should easily be able to switch back using another button or change it all over to a checkbox.