I wanted to transfer data from listview1 to listview2 when clicked

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 2119 Views - Last Post: 29 December 2012 - 04:05 AM Rate Topic: -----

#1 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 02:16 AM

hi, i am facing a problem for my person project. I am able to display the item that i click in listview1 to listview2's columnheader because i point them to columnheader. I wanted to know how can i pass the data into the listview2 when data is clicked in listview1. I connect vb to access and the data in listview1 is pull from access db.


I am very new to listview, hope to get reply soon. Thank you in advance.

Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: I wanted to transfer data from listview1 to listview2 when clicked

#2 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 02:37 AM

<myListBox>.Items.add(<otherlistbox>.Text)
Was This Post Helpful? 1
  • +
  • -

#3 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 02:43 AM

View Postkai_itz me, on 25 December 2012 - 02:37 AM, said:

<myListBox>.Items.add(<otherlistbox>.Text)

Thanks for the reply kai_itz me, i appreciate your effort.
I am using "listview" not listbox. I am able to transfer data to listbox. but i wanna transfer data between 2 "LISTVIEW"
Was This Post Helpful? 0
  • +
  • -

#4 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 02:55 AM

Are you looking to copy a single record that is clicked on or the whole listview?

As the screenshots look like .Net, check out this link as a starting point.

This post has been edited by maj3091: 25 December 2012 - 02:59 AM

Was This Post Helpful? 0
  • +
  • -

#5 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 02:55 AM

sorry ! i just misread

can u tell me .. are u going to copy data over a single form or there are two forms.
Was This Post Helpful? 0
  • +
  • -

#6 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 03:00 AM

View Postmaj3091, on 25 December 2012 - 02:55 AM, said:

Are you looking to copy a single record that is clicked on or the whole listview?

Just the data that clicked.. i mean the whole row and the data example :
if user click item no '5464' ... copy the whole row including item name, price and ect
Was This Post Helpful? 0
  • +
  • -

#7 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 03:07 AM

View Postmaj3091, on 25 December 2012 - 02:55 AM, said:

Are you looking to copy a single record that is clicked on or the whole listview?

Just the data that clicked.. i mean the whole row and the data example :
if user click item no '5464' ... copy the whole row including item name, price and ect

View Postkai_itz me, on 25 December 2012 - 02:55 AM, said:

sorry ! i just misread

can u tell me .. are u going to copy data over a single form or there are two forms.


just copy single data that clicked from listview1 to listview2....

View Postmaj3091, on 25 December 2012 - 02:55 AM, said:

Are you looking to copy a single record that is clicked on or the whole listview?

As the screenshots look like .Net, check out this link as a starting point.


Cool but that link is about copy a listview to another listview... i just want to copy a data that is clicked.
Was This Post Helpful? 0
  • +
  • -

#8 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 03:34 AM

i dont have enough knowlege about listview so u can check this link..
i hope this will solve ur doubt

My link
Was This Post Helpful? 0
  • +
  • -

#9 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 03:48 AM

Why do i getting this error : type 'Listview' is not defined when i try to implement this code from here and alter it to my needs.
http://vbcity.com/forums/t/132841.aspx
Was This Post Helpful? 0
  • +
  • -

#10 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 03:56 AM

exectly im not sure...but It sounds like you are missing a reference.

If you added the project source code, then you need to right-click on the project and select Add Reference..., select the Projects tab, and choose the ListView project.
Was This Post Helpful? 0
  • +
  • -

#11 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 04:20 AM

try importing this lib
Imports System.Windows.Forms.ListView


also check these...
My link1

My link2

This post has been edited by kai_itz me: 25 December 2012 - 04:56 AM

Was This Post Helpful? 0
  • +
  • -

#12 maj3091  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,797
  • Joined: 26-March 09

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 05:22 AM

View Postimchivaa, on 25 December 2012 - 10:07 AM, said:

Cool but that link is about copy a listview to another listview... i just want to copy a data that is clicked.


It is for copying all listviewitems, but you should be able to adapt it using the selected index of the item that is clicked in your source list view.
Was This Post Helpful? 0
  • +
  • -

#13 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 05:33 AM

This link have the exact problem that i am facing right now.
I tired to import the library, but i get 3error

*Type 'ListItem' is notdefined
*Error 2 'ListItems' is not a member of 'System.Windows.Forms.ListView'.
*Error 3 'SubItems' is not a member of 'System.Windows.Forms.ListView.SelectedListViewItemCollection'.

http://www.vbforums....nother-listview

View Postkai_itz me, on 25 December 2012 - 04:20 AM, said:

try importing this lib
Imports System.Windows.Forms.ListView


also check these...
My link1

My link2


Hye kai_itz me :
Thank you a bunch man! It's working...
Just this simple code :

For Each item As ListViewItem In Me.ListView1.SelectedItems
item.Remove()
Me.ListView2.Items.Add(item)
Next

And maj3091, thanks for respond for my help. Thanks you both. ;)

Now i am facing another problem, it remove the item before adding it to listview2.

For Each item As ListViewItem In Me.ListView1.SelectedItems
item.Remove()
Me.ListView2.Items.Add(item)
Next

How to prevent it from removing it and add it to the listview2?
Was This Post Helpful? 0
  • +
  • -

#14 imchivaa  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 25-December 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 25 December 2012 - 05:40 AM

For Each item As ListViewItem In Me.ListView3.SelectedItems
item.Remove()
Me.lv1.Items.Add(item)
Next
ListView3.Refresh() 'Not working

when i click an item in listview3.. it remove the item from listview3 and add it to lv1.
but when you refresh listview3... all item display back
so i added this code after the next
listview3.update() but it's not working
Was This Post Helpful? 0
  • +
  • -

#15 kai_itz me  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 159
  • Joined: 03-August 12

Re: I wanted to transfer data from listview1 to listview2 when clicked

Posted 26 December 2012 - 12:47 AM

Quote

For Each item As ListViewItem In Me.ListView1.SelectedItems
item.Remove()
Me.ListView2.Items.Add(item)
Next

How to prevent it from removing it and add it to the listview2?



ACTUALLY THIS CODE WORKS AS CUT AND PASTE..
if u try removing

item.Remove()


IT GIVES U ERROR:
Cannot add or insert the item 'WHATEVER' in more than one place. You must first remove it from its current location.

so i will suggest u to use clone()

   For Each item As ListViewItem In Me.ListView1.SelectedItems
            item.Clone()
            Me.ListView2.Items.Add(item.Clone())
        Next



it will work for u ....

This post has been edited by kai_itz me: 26 December 2012 - 01:35 AM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2