Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple (?) question re Listbox repositioning 1

Status
Not open for further replies.

vfp7guy

Programmer
Jul 2, 2002
45
CA
Maybe I can't see the forest for the trees, but I got myself lost working on this problem.

In a 'User-access-rights' portion of a password-management form, I have a page on a pageframe that has 2 listboxes; the left one is initially populated with all available accessible forms, and the right one is for the selected forms for that user. I use the normal drag-and-drop, double-click, directional move buttons (all or selected, including multi-select), etc., and they have all been working properly.

If assigning for a new user, all the available selections properly show in the left listbox and the right one is properly empty. Similarly, if I go to this page via the EDIT button, my Initialize method will initially load the left with ALL forms, then do a multi-select of the already-selected forms from the user-rights table, then execute the MOVE button to move these to the right listbox. So far so good - this all works properly.

The only problem is that sometimes after the method that initializes (via the above MOVE) based on existing selections, the contents of the left listbox are out of sight and I need to use the scrollbars to scroll up to see them. They are always properly there, but the initial visibility seems to depend on what their relative positions were prior to the autoexecution of the MOVE button.

I don't want to automatically go to the top listindex every time the MOVE button is clicked because the user will typically go sequentially down through the alpha-sorted list and choose access rights for the password and move them one at a time, but I do want the initialization of the unselected rights to not need scrolling up, otherwise the administrator may think that there are no unassigned rights available.

I'm probably missing something very simple.
 
There is no need to put ListIndex = 1 to Move Button, Just put it in Initialize Methd AFTER you invoke MoveButton.Click Event
Something like:

*** Initialize Method:
Code:
thisform.SelectAllRights() && Or something MultiSelect all choosed Rights before
thisform.MoveButton.Click() && or Move all Selected to Second ListBox
thisform.ListBox1.ListIndex = 1 && reposition first ListBox

Borislav Borissov
 
Thanks a lot ... so simple, yet so easily overlooked ...

That did the trick (I feel embarassed).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top