Selected item to top of ListBox

HARRY

Active Member
Licensed User
Hi,

In a program I have a ListBox with many items. I want to help the user in scrolling as I know roughly which item he will need. I managed to select programmatically that item. It appears at the bottom of the ListBox. Does somebody know a possibility to get programmatically that selected item on the top of the list?

Harry
 

taximania

Well-Known Member
Licensed User
Can't you use the index and a temp variable to swap the two.

Sorry for the short reply. I didn't have time to test what I said :sign0137:
 

Cableguy

Expert
Licensed User
That's a thought one...
If you DO know what the probable choice is, then delete the item from the list box, and then add ity again to the first position....
listbox.additem(0)="myItem"
 

HARRY

Active Member
Licensed User
Hi,

Thanks for your suggestions. However, as the list is in alphabetic sequence, I cannot move items to another place. I found myself the following solution:

Find the index of the probable candidate
Add to it the number of visible items -1
Check on the Count and correct if necessary
Select the raised index
Select the original index

Using Visible is false and true around this operation gives an acceptable performance (as it does with various Table operations).

Harry
 
Top