Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_vb thread: listview drag drop


Message #1 by "Pankaj" <pa_inbox@h...> on Thu, 9 Jan 2003 14:56:19 -0800
Got it... Listview sorted property was true so every time when the indexes
changes it automatically again sorted itself .. hence no visual change


"Pankaj" <pa_inbox@h...> wrote in message news:250573@p..._vb...
>
> Hi All :
>
> I am using following code to perfrom drag drop .... the items get added
and
> removed in drag_drop
> event ( checked the lvwtables.listitems.count in immediate window) but
> doesn't get visually reflected
> in listview besides putting ensurevisible and refreash methods ... which
> anyways should not be required.... Any Ideas....
>
> -TIA
> Pankaj
>
> --------------- Code Start----------------------
>
> Dim indrag As Boolean ' Flag that signals a Drag Drop operation.
> Dim DraggedItems As New Collection
>
> Private Sub lvwTables_DragDrop(Source As Control, x As Single, y As
Single)
>
>    Dim itmX As ListItem
>    Dim linew As ListItem
>
>    ' If user didn't move mouse or released it over an invalid area.
>
>    If lvwTables.DropHighlight Is Nothing Then
>       indrag = False
>       Exit Sub
>    Else
>       For Each itmX In DraggedItems
>         If itmX.Index <> lvwTables.DropHighlight.Index Then
>             Set linew 
> lvwTables.ListItems.Add(lvwTables.DropHighlight.Index, , itmX.Text)
>             'linew.SubItems(1) = itmX.SubItems(1)
>             linew.Selected = True
>             lvwTables.ListItems.Remove itmX.Index
>             linew.EnsureVisible
>         End If
>       Next
>       lvwTables.Refresh
>       Set lvwTables.DropHighlight = Nothing
>       indrag = False
>       Exit Sub
>    End If
> End Sub
>
> Private Sub lvwTables_DragOver(Source As Control, x As Single, y As
Single,
> State As Integer)
>     Set lvwTables.DropHighlight = lvwTables.HitTest(x, y)
> End Sub
>
>
> Private Sub lvwTables_MouseDown(Button As Integer, Shift As Integer, x As
> Single, y As Single)
>     Dim itmX As ListItem
>     Set DraggedItems = New Collection
>     DraggedItems.Add lvwTables.HitTest(x, y)
>     Set lvwTables.DropHighlight = Nothing
> End Sub
>
> Private Sub lvwTables_MouseMove(Button As Integer, Shift As Integer, x As
> Single, y As Single)
>    If Button = vbLeftButton Then ' Signal a Drag operation.
>       indrag = True ' Set the flag to true.
>       ' Set the drag icon with the CreateDragImage method.
>       lvwTables.DragIcon = lvwTables.SelectedItem.CreateDragImage
>       lvwTables.Drag vbBeginDrag ' Drag operation.
>    End If
> End Sub
>
>
>
>
>



  Return to Index