Results 1 to 7 of 7

Thread: copy text out of a ListBox

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    4
    Hi dudes,
    i have a listbox with many entrys and i want to copy these manualy into my clipboard. but i can´t use strg+c or rightclick -> copy. any ideas how i can fix it?


    thx alot,
    bimsel

  2. #2
    Lively Member
    Join Date
    Mar 1999
    Posts
    93
    You cannot do it with listbox. Try to use a combobox instead and set its style to DropDown Combo
    Regards,
    Vit

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    This will allow you to use ctrl-c to copy the selected listbox to the clipboard.
    Code:
    Private Sub List1_KeyDown(KeyCode As Integer, Shift As Integer)
        Dim ShiftTest As Integer
        
        ShiftTest = Shift And 7
        If ShiftTest = 2 Then
            If KeyCode = vbKeyC Then
                Clipboard.SetText List1.List(List1.ListIndex)
            End If
        End If
        
    End Sub

  4. #4
    Guest
    Instead of List1.List(List1.ListIndex), you could use List1.Text that gets the text of the selected item.

  5. #5
    Guest
    If you want use a menu, use this method. First, make a Menu called mnuEdit and make a sub menu called mnuCopy. Set the Visible property for mnuEdit to False.

    Code:
    Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
        If Button = 2 Then
            If List1.Text <> "" Then PopupMenu mnuEdit
        End If
        
    End Sub
    
    Private Sub mnuCopy_Click()
    
        Clipboard.SetText List1.List(List1.ListIndex)
    
    End Sub

  6. #6
    Guest
    When copying to a listbox, it copies the number and then copies another one. So the past number is deleted and replaced with a new one.

    Here is what you do:
    Code:
    Needed:  Textbox, Listbox
    
    For i = 0 To list1.ListCount - 1
    text1.Text = text1.Text & i & " " 'Chr$(13) + Chr$(10) can be used to skip a line.
    Next i
    Clipboard.SetText text1

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    4
    Thanks,
    Its working now

    Bimsel

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width