Results 1 to 5 of 5

Thread: Can The User Copy Out Of Listboxes?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    20

    Can The User Copy Out Of Listboxes?

    Hey,

    Sorry for the newbie question. I've got my first ever program and it's working. Having tested it a bit it would be helpful for the user to be able to copy the results printed in a listbox into an email or text doc. Just somewhere where they can make a note of it really.

    Is this possible? Is there something I need to do to enable it? All the google results I found were referring more to doing this in code. I literally want to be able to support Ctrl+A, the Ctrl+C straight out of the program to wherever the user wants.

    Thanks!

  2. #2
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Can The User Copy Out Of Listboxes?

    Is there a reason why the items are in a listbox then and not just in a multi-line textbox or RichTextBox ? (as both of those controls would support this without any extra work and you can make both of them Read-Only)
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Can The User Copy Out Of Listboxes?

    Not by default, because there's no way to know exactly what format to copy the data in. You could create a String array but what if there's more data bound behind the scenes? You could always write your own custom code to place the appropriate data on the clipboard yourself, then the user can paste as normal.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Aug 2009
    Posts
    20

    Re: Can The User Copy Out Of Listboxes?

    Chris, it's a listbox because it was my first program and the array seemed quite hard to master. I'm extracting a list of files using Excel as a database and then checking all the names for duplicates. The duplicates then get added to a final listbox. Would it be easy to turn this into a multiline text box?

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: Can The User Copy Out Of Listboxes?

    It would be easy to change it to a multiline textbox yeah as long as your program design does not rely on the fact that this is a listbox and users can actually select individual items in it. You would just replace the listbox with a textbox and then wherever you have got
    Code:
    listbox.items.add("item text here")
    you just replace it with this
    Code:
    textbox.AppendText("item text here" & vbNewLine)
    (oh and dont forget to set the MultiLine property of the textbox to True
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


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