Solved

ListView items copy to clipboard

Posted on 2004-10-23
2,543 Views
Last Modified: 2011-04-14
Greetings,

I have a ListView control (in Report view, with a entire line section) with 10 or more lines and 6 columns. Now I wish to add a Copy function that will copy the selected lines (and all of the sub items) to clipboard in this format: assuming lines 1, 2 and 3 are selected.

Line1
A B C D E

Line 2
A B C D E

Line 3
F G H I J

How can I accomplish this?

Thanks1
0
Question by:sramesh2k
    2 Comments
     
    LVL 19

    Accepted Solution

    by:
    Private Sub Command1_Click()
    Dim tLoop As Integer, mLoop As Integer, toClip As String, tmpSel As String
    Clipboard.Clear
    For tLoop = 1 To ListView1.ListItems.Count
        If ListView1.ListItems(tLoop).Selected Then
            tmpSel = ListView1.ListItems(tLoop).Text
            For mLoop = 1 To ListView1.ColumnHeaders.Count - 2
                    tmpSel = tmpSel & chr(32) & ListView1.ListItems(tLoop).ListSubItems(mLoop).Text
            Next mLoop
            toClip = toClip & tmpSel & vbNewLine
        End If
    Next tLoop
    Clipboard.SetText toClip
    End Sub

    S
    0
     
    LVL 34

    Author Comment

    by:sramesh2k
    It works! Thanks, Shauli.
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Learn The Basics of Ethical Hacking & Pen Testing

    Computer and network security is one of the fastest growing and most essential industries in technology, meaning companies will pay big bucks for ethical hackers. This is the perfect course to leap into this lucrative career, learning how to use ethical hacking to reveal ...

    Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

    856 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now