|
-
Apr 24th, 2000, 01:00 PM
#1
Thread Starter
Hyperactive Member
I have this listview in report mode, but I want the user to be able to change the order of things, preferably by dragging and dropping, inside that one box. If you have any idea, I'd be glad to hear. note: it's not a listbox, and there aren't two boxes, just one listview that needs it's order changed around a bit.
bob
-
Apr 24th, 2000, 11:13 PM
#2
Addicted Member
Right-click the listview and choose 'properties', and make sure the AllowColumnReorder is checked. Doesn't that do what you want? Sorry if I'm being thick, but from what you've said, it seems to be what you're after.
-
Apr 25th, 2000, 12:55 AM
#3
Thread Starter
Hyperactive Member
Not the columns, but the rows. If the user has:
1 a b c
2 d e f
3 g h i
I want them to be able to drag and drop the ROWS:
1 a b c
3 g h i
2 d e f
-
Apr 25th, 2000, 06:18 PM
#4
Addicted Member
Oh right. I had a piece of code to do exactly that. As I recall, it only worked for moving single rows - not blocks. Suppose you could always modify it.
Let me have a dig around and see if I can find it.
-
Apr 26th, 2000, 06:08 AM
#5
Thread Starter
Hyperactive Member
That's exactly what I need
That is exactly what i want to do. It would be wonderful if you could find that.
thanks,
bob
-
Apr 26th, 2000, 02:33 PM
#6
Addicted Member
Hi Bob,
I dunno where you are, but I'm in the UK and it's 8:20am, just arrived at work. I searched for that bit of code last night at home, and it's nowhere to be found. The best I can offer at the moment is a simplified explanation of how it worked.
Basically when you click on a listitem, the number of the item you clicked is stored in one parameter. When you move the mouse and release it, the number of the item under the mousepointer is stored in another parameter, giving you a start point and end point for the listitems you need to modify. For example, if you pick row 3 and want to move it to row 5, then item 3 is saved to a temporary buffer, rows 4 and 5 are moved up one row, and the item which was at row 3, is pasted to row 5. All of that is simple enough in concept.
I've just had a go at writing the code to do this, and the only problem I haven't been able to figure out (in the 10 minutes or so that I spent on it), is how to work out which row is under the mouse pointer when the mouse button is released.
You'll also need to access the Properties page for the ListView, and set the following:-
OLEDragMode = 1 - ccOLEDragAutomatic
OLEDropMode = 1 - ccOLEDropManual
Hope that's of some use to you. In the meantime, I'll have another look for that piece of code, and post here again if I have any luck.
-
Apr 27th, 2000, 09:37 AM
#7
Thread Starter
Hyperactive Member
Good news
I got it to work-mostly. Here's what I did:
Code:
Private Sub ListView1_DragDrop(Source As Control, x As Single, y As Single)
strItem1 = ListView1.SelectedItem.Text
strItem2 = ListView1.SelectedItem.SubItems(1)
Set ListView1.DropHighlight = ListView1.HitTest(x, y)
ListView1.DropHighlight = ListView1.ListItems.Count
Set Itemx = ListView1.ListItems.Add(ListView1.DropHighlight.Index)
Itemx.Text = strItem1
Itemx.SubItems(1) = strItem2
ListView1.ListItems.Remove (ListView1.SelectedItem.Index)
Set ListView1.DropHighlight = Nothing
End Sub
Private Sub ListView1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
ListView1.Drag vbBeginDrag
End If
End Sub
It works for dragging and dropping, but there are two problems that I'm not sure how to solve now. The first is that when I drag it off or too far down or up, it gives me an error(because the index is all messed up I think). The second is that it drops it above the one I drop it on. Normally programs drop it below the selected one, and that's what I want to do, but it doesn't work when I add + 1 to the DropHighlight.Index part of the Add statement. Could you help me with this maybe?
thanks,
bob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|