copy listview row
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: copy listview row

  1. #1
    Join Date
    Jul 2005
    Posts
    65

    copy listview row

    hi.........
    can anyone help me? how to copy a row from listview to another listview.
    i need that code ASAP.
    thanks

  2. #2
    Join Date
    May 2005
    Posts
    42

    Re: copy listview row

    HI
    Let suppose u have lvw1 and lvw2 both having 2 cols.
    so code to copy the selected row from lvw1 to lvw2 is

    'copies the header of lvw1 to lvw2 header
    lvw2.ListItems(index).Add=lvw1.ListItems(lvw1.SelectedItem).Text
    'copies the col next to header from lvw1 to lvw2
    lvw2.ListItems.Item(index).SubItems(1)=lvw1.ListItems.Item(index).SubItems(1)

    thus u can copy the selected row from lvw1 to lvw2 at specified locatipon

    Dev-6

  3. #3
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,090

  4. #4
    Join Date
    Jul 2005
    Posts
    65

    Re: copy listview row

    i have done dev-6 coding but it does't work. actually i still new in vb so i can't figure it out.

    for your information i have 2 listview in the same form and each of them got 3 same column. please help me...........

    one more thing, how can i delete a list from listview
    Last edited by passwordguru; September 14th, 2005 at 02:50 AM.

  5. #5
    Join Date
    May 2005
    Posts
    42

    Thumbs up Re: copy listview row

    Hi ,
    i have developed one small prj for u its code as follows

    Option Explicit
    Dim index As Integer

    Private Sub cmdCopy_Click()
    Dim curindex As Integer
    curindex = lvw1.SelectedItem.index
    lvw2.ListItems.Add = lvw1.ListItems(curindex).Text
    'copies the col next to header from lvw1 to lvw2
    lvw2.ListItems.Item(index).SubItems(1) = lvw1.ListItems.Item(curindex).SubItems(1)
    lvw2.ListItems.Item(index).SubItems(2) = lvw1.ListItems.Item(curindex).SubItems(2)
    index = index + 1
    End Sub

    Private Sub Form_Load()
    Dim lint_index As Integer
    index = 1
    'For lint_index = 0 To 5
    lint_index = 0
    lvw1.ListItems.Add(lint_index + 1) = "aaa"
    lvw1.ListItems.Item(lint_index + 1).SubItems(1) = "1"
    lvw1.ListItems.Item(lint_index + 1).SubItems(2) = "12345"
    lint_index = 1
    lvw1.ListItems.Add(lint_index + 1) = "bbb"
    lvw1.ListItems.Item(lint_index + 1).SubItems(1) = "2"
    lvw1.ListItems.Item(lint_index + 1).SubItems(2) = "12345"
    lint_index = 2
    lvw1.ListItems.Add(lint_index + 1) = "ccc"
    lvw1.ListItems.Item(lint_index + 1).SubItems(1) = "3"
    lvw1.ListItems.Item(lint_index + 1).SubItems(2) = "12345"
    lint_index = 3
    lvw1.ListItems.Add(lint_index + 1) = "ddd"
    lvw1.ListItems.Item(lint_index + 1).SubItems(1) = "4"
    lvw1.ListItems.Item(lint_index + 1).SubItems(2) = "12345"
    'Next lint_index
    End Sub

    if u find this article helpful plz dnt forget to Rate me.....
    here is snap shot and code is attached...
    Attached Files Attached Files

  6. #6
    Join Date
    Jul 2005
    Posts
    65

    Re: copy listview row

    hi dev-6

    thanks for the code.............
    it really help me a lot.........
    u just solve my problem..............
    thanks again

  7. #7
    Join Date
    May 2005
    Posts
    42

    Smile Re: copy listview row

    So Now U Can Rate Me ..isnt It?...:-)

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center