drag to new listbox and, delete from the original listbox

  1. 3 weeks ago

    GANESALINGAM N

    May 11 Testers, Xojo Pro

    Hello,
    I am able to drag successfully an item from one Listbox to another. However, the problem is that at the end of the successful drag, a copy of the item continues to remain on the original listbox. So, this leaves me with 2 of the same item: one in the original listbox and another in the second listbox where I dragged the item to.

    How could I delete the item in the original listbox, once it has been dragged to the new list box?

    Thanks

    @GANESALINGAMNAENTHIRAN now I can now drag and move from one listbox to another listbox

    How your user can made a Copy ?

  2. Gary S

    May 11 St Augustine FL

    This is how I do it.
    In the dragrow event, save the name of the from listbox to a string property on the page and save the row to an integer property on the page. In the DropObject event of all the listboxes call a method, mine is named LbDropped. In the method I use a select case to pick the LbName that I saved and do exampleLB.RemoveRow(ThesavedRow_Property)

     Select Case LbName
      case "LbNotDisp"
        LbNotDisp.removerow(TheRow)
      case "LbReady"
        LbReady.removerow(TheRow)
      case "LbParts"
        LbParts.removerow(TheRow)
      case "LbSent"
        LbSent.removerow(TheRow)
      case "LbService"
        LbService.removerow(TheRow)
      case "LbWait"
        LbWait.removerow(TheRow)
      end select

    Thanks

  3. Rick A

    May 11 Testers, Xojo Pro (Brazil. UTC-3:00)
    Edited 3 weeks ago
    Class Window1 Inherits Window
    
        Properties
        itemDragged As Pair
    
        Window1 Control Listbox1:
    
        Function DragRow(drag As DragItem, row As Integer) As Boolean 
            itemDragged = Me : row // Me = origin listbox 
            drag.Text = "Text" // Just enable drag 
            Return True
        End Function
    
        Sub DropObject(obj As DragItem, action As Integer) 
            me.AddRow ListBox(itemDragged.Left).Cell(itemDragged.Right, 0) // Add to dest one cell example
            ListBox(itemDragged.Left).RemoveRow(itemDragged.Right) // Remove origin row
        End Sub
    
        Sub Open() 
            Me.AcceptTextDrop 
        End Sub 
    
        Window1 Control Listbox2:
    
        Function DragRow(drag As DragItem, row As Integer) As Boolean 
            itemDragged = Me : row // Me = origin listbox 
            drag.Text = "Text" // Just enable drag 
            Return True
        End Function
    
        Sub DropObject(obj As DragItem, action As Integer) 
            me.AddRow ListBox(itemDragged.Left).Cell(itemDragged.Right, 0) // Add to dest one cell example
            ListBox(itemDragged.Left).RemoveRow(itemDragged.Right) // Remove origin row
        End Sub
    
        Sub Open() 
            Me.AcceptTextDrop 
        End Sub 
    
    End Class
    

    -image-

  4. GANESALINGAM N

    May 11 Testers, Xojo Pro

    Thank you very much Gary and Rick! I will try both methods and let you know. Warm regards, Naren

  5. 2 weeks ago

    GANESALINGAM N

    May 21 Testers, Xojo Pro

    Hello Rick,
    Many thanks! Your advice worked nicely - now I can now drag and move from one listbox to another listbox (the item from the original listbox disappears). This allows for moving one item at a time. How might I do this for (i.e.move) multiple items from one listbox to another (and delete selected items from the original listbox). I guess have to make the itemDragged as array. Thanks

  6. Emile S

    May 21 Answer Europe (France, Strasbourg)

    @GANESALINGAMNAENTHIRAN now I can now drag and move from one listbox to another listbox

    How your user can made a Copy ?

  7. Rick A

    May 21 Testers, Xojo Pro (Brazil. UTC-3:00)

    @GANESALINGAMNAENTHIRAN This allows for moving one item at a time. How might I do this for (i.e.move) multiple items from one listbox to another

    Change the logic here:

    itemDragged = Me : row // Me = origin listbox

    And instead of "row" annotate and pass "rows", and process all them.

  8. GANESALINGAM N

    May 21 Testers, Xojo Pro

    Thanks!
    When I changed to,

    itemDragged=Me:rows //Me=origin listbox

    I get the following error message: 'This item does not exist', with 'rows' being highlighted.

    Should I create an array itemDragged().

    Thanks

or Sign Up to reply!