Say I have a listview control with several items in it. How would I allow the user to drag and drop items to rearrange them in the control.
The listview control is in report view, with the full-row select extended style.
Thanks in advance.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your ListView’s
WM_LBUTTONDOWNhandler, store the currently selected item index somewhere.In your ListView’s
WM_LBUTTONUPhandler, useListView_HitTest()to determine which item is under the cursor. If different than the stored index, then useListView_DeleteItem()andListView_InsertItem()to “move” the “dragged” item to the new index.(Optionally) To help the user see where the item is being “dragged” to, in your ListView’s
WM_MOUSEMOVEhandler, useListView_HitTest()to determine which item is under the cursor, then useListView_SetItemState()to disable/enable theLVIS_DROPHILITEDstate for the previously “highlighted” item (if any) and to “highlight” the current item.