home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.visual.basic      MS Visual Basic discussions, NOT dot-net      10,840 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 9,542 of 10,840   
   John Guarnieri to Rick Rothstein   
   Re: ListBox Drag Items   
   04 Jun 05 22:21:47   
   
   From: jguarnieri@adelphia.net   
      
   Ok Thanks again I think I have a soultion to avoid the shift key I'll work   
   it out and get back to you   
      
      
      
   "Rick Rothstein"  wrote in message   
   news:iLudnQyT8uhhJzzfRVn-vw@comcast.com...   
   > > Thanks, I'll give it a try, curious, I don't even see  .ItemData in   
   > your   
   > > code. How does it get moved?   
   >   
   > It doesn't! Now it would have if I had copied the correct file from   
   > my archives though. Try this code instead of what I posted originally.   
   >   
   > ********START PASTE********   
   > Dim DragIndex As Long   
   > Dim OldItemData As Long   
   >   
   > Private Sub Form_Load()   
   >   Dim X As Long   
   >   ' Just load the ListBox up with something   
   >   With List1   
   >     For X = 0 To 10   
   >       .AddItem "Item #" & CStr(X + 1)   
   >       .ItemData(X) = X + 1   
   >     Next   
   >   End With   
   > End Sub   
   >   
   > Private Sub List1_MouseDown(Button As Integer, _   
   >             Shift As Integer, X As Single, Y As Single)   
   >   With List1   
   >     DragIndex = .ListIndex   
   >   End With   
   > End Sub   
   >   
   > Private Sub List1_MouseUp(Button As Integer, _   
   >             Shift As Integer, X As Single, Y As Single)   
   >   With List1   
   >     If DragIndex <> .ListIndex Then   
   >       ListText = .List(DragIndex)   
   >       OldItemData = .ItemData(DragIndex)   
   >       .RemoveItem DragIndex   
   >       .AddItem ListText, .ListIndex + Abs(Shift = vbShiftMask)   
   >       .ItemData(.NewIndex) = OldItemData   
   >       .ListIndex = .NewIndex   
   >     End If   
   >   End With   
   > End Sub   
   > ********END PASTE********   
   >   
   > You can use this code (placed in a CommandButton Click event for   
   > convenience) to view the end result.   
   >   
   >     Private Sub Command1_Click()   
   >       Dim X As Long   
   >       For X = 0 To 10   
   >         Debug.Print List1.List(X), List1.ItemData(X)   
   >       Next   
   >     End Sub   
   >   
   > Rick - MVP   
   >   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca