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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listboxes, Checkboxes, and Moverbars

Status
Not open for further replies.

Keeper00

Programmer
Jul 17, 2003
13
US
I have created a listbox with checkboxes, using bmps, and also enabled the moverbars on the control. The problem I am having is when the item is checked and then that same item is moved in the list. Once the item is moved, when the user selects another item to be checked, it checks the item that was in the same position before the move. Example, I have 5 items in the list 1-5. I check item 4 and move it to position number 1 in the list, 4,1,2,3,5. When I check number 2 in the list, it checks number 1 in the list not the line I have currently highlighted. This is the code I have in the Double Click event:

LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF LASTKEY()!= 5 AND LASTKEY() != 24
IF ThisForm.selectitemsel(This.ListItemID)=0
This.Picture(This.ListItemID)="checkbx.bmp"
ThisForm.selectitemsel(This.ListItemID)=1
ELSE
IF ThisForm.selectitemsel(This.ListItemID)=1
This.Picture(This.ListItemID)="box.bmp"
ThisForm.selectitemsel(This.ListItemID)=0
ENDIF
ENDIF
ENDIF

The list is setup with a Rowsourcetype = 0
Rowsource = tempselectlist (updatable cursor)
Moverbars = .t.
Columncount = 1

How do I keep what is selected, and when it is moved make sure that the next thing is selected is marked properly?
 
Are you using ID's to get to the items, but taking away the Index from the table?

After an item is moved, it's ID remains the same, but now the Index has changed: Dbl-Clicking the 3rd item will always be Index 3, no matter how things have moved around.

If you don't specify the ID when adding them to start with, the ID==the Index.

Looking at your code, it seems you are using the ID properly... maybe you should instead use the Index, then use the IndexToItemID method call to workaround and get the correct ID.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top