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
Printable View
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
You cannot do it with listbox. Try to use a combobox instead and set its style to DropDown Combo
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
Instead of List1.List(List1.ListIndex), you could use List1.Text that gets the text of the selected item.
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
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
Thanks,
Its working now
Bimsel