Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Copy Listitems In Listview To Another Listview?


I have "LISTVIEW 1" with 8 columnheader, I just want to show only 2 columnheader together with its items in "LISTVIEW 2" . How I can do that? Have sample as starting point




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Listview Listitems
Have filled a listview with checkboxes with ID, Lastname and firstname. I now want to add the ID to a collection but am having trouble identifying that all are in the collection. Here is what I have:


Code:
Dim i As Integer
Dim cCol As New Collection
With listview1
For i = 1 To .ListItems.Count
If .ListItems(i).Checked Then
lngID = .ListItems(i).Checked ' this returns True/False
lngid = .selecteditem 'returns the current item only
cCol.Add lngID
End If
Next i
End With
When one or all checkboxes are checked, I would like to 'collect' them to further manipulate the data.

Any help would be greatly appreciated.

Thanx.

Kim

Vb6 Listview Listitems?
I am having problems adding items to a listview with multiple headers in the details view type. Here is my code below, followed by the error I get when executing the code.

CODE:

vb Code:
Open "C:WINDOWSTEMPgamLST" For Input As #1        For a = 1 To 5 Step 1            Line Input #1, TempSTR                        frmMain.ListView1.ListItems(a).Bold = Split(TempSTR, ",")(0)            frmMain.ListView1.ListItems(a).Ghosted = Split(TempSTR, ",")(1)            frmMain.ListView1.ListItems(a).Text = Split(TempSTR, ",")(2)        Next a    Close #1


ERROR:

Index out of bounds


--

On another hand, the file being opened is:

true,true,Test Program 1
false,true,Test Program 2
false,false,Test Program 3
true,false,Test Program 4
true,true,Test Program 5


--

Also, if this helps any, I have attached a picture of the listview's setup.

Listview Help: With Listitems
I am filling listitems with a recordset. I have fields like Count, Timestamp etc. How can I know at run time, the index of the listitem whose recordset reads Count? i.e it should browse through the listitems and find the index of rs!Count

Thanks for any input

Listview Help Please: With Listitems
ok, here is my latest challenge with listview.

I have a menu bar where I can add/remove the listview column headers dynamically. I succesfully implemented this considering 'AllowColumnReorder' property set to true.

Now, when I reorder the columns and I add/remove the column headers, the corresponding listitems are not being added/removed.

How can I take care so that, the corresponding listitem is added/removed. Thanks for all the input.

Find ListView ListItems Using Key
I tried searching this out, but "key" was too short a word and "ListView" and "Find" were way too common.

How to find ListView ListItems use key to find, please.

Passing A Listview.listitems
I am trying to pass a listview to a sub and I can only get it to work if i use a variant. is there a way i can get this to work by declaring it a listview instead?

This is basically what I have:


Code:
Public Sub FillGridData()
Dim lview as ListView

Set lView = MDIMain.ActiveForm.ListView
ChangeListColor lview.ListItems(1)
End Sub

Code:
Public Sub ChangeListColor(list As Variant) '<--This has to be variant?
list.ListSubItems(8).ForeColor = &HC0&
End Sub

Listview Listitems Question
Hi Guys,

I store a key in the first column of my listview. example

row 1,column1 = 750
row 2,column1 = 756

I perform a check for the quantity of the item no's above and if there is 0 then I add the key to a collection.

Then I loop through the collection and I need to loop through my listview items to check where the item number in the collection is equal to the item number in the listview.

but how can I ensure that if there are 3 or more items that match in the listview are selected and visible.

At the moment it doesn't work because each time I loop through the collection it starts the loop all over again for the listview.

Here's my code:


Code:
lvwNote.SetFocus
For k = 1 To Idont.count
notid = CInt(Idont(k))
For l = 1 To lvwNote.ListItems.count
If notid = CInt(lvwNote.ListItems(l).Text) Then
lvwNote.ListItems(k).Selected = True
lvwNote.ListItems(k).EnsureVisible

End If
Next l
Next k

ListItems Swapping In ListView
Hi,

Does anyone know how I can swap 2 ListItems in a ListView control when I press a button?

Thanks, Lior

Listview And Checked Listitems
I have a check listview. How do I get the listitem text to be highlighted when I check or uncheck the associated checkbox? I can get it to check by click on the text or highlighting the text with arrow keys but not the other way around. Thanks

Add Method In Listview.ListItems
I use a ListView control to implement a list of string. I don't do it with the usual ListBox 'cause I want to sort strings in descending order, and this is allowed by a ListView but no by ListBoxes.

When I want to add a string to my ListView I do the following:


mylistview.ListItems.Add(0,"",mystring)




VB says to me "Compile Error: '=' expected".

Where am I wrong?

Thank you for your help

ListView Visible ListItems
Is there a way to determine what ListItems in a Listview are visible within the view area?

The ListBox control has a TopIndex property that gives you a index number, but the Listview does not seem to have a equivelant

I know there is a GetFirstvisible method but this is text information not a index value

John G

ListView.ListItems.Add From Another Form/module
Greets!

I'm new to this forum, and am still quite the newbie at VB.

I'd like to add items to a ListView on my main form from another form or module, and I'm having one heck of a time.

Here's the gist of what I'm trying to do...

----[frmMain]----
Public Sub DrawList()
...
lvw.ListItems.Add , , ("Add Item")
...
End Sub

Call DrawList
----[end form]----

"Call DrawList" from the main form properly adds items to control "lvw".

However, neither of these two techiniques work:

1)
----[frmOther]----
Call frmMain.DrawList
----[end form]----

2)
----[frmOther]----
frmMain.lvw.ListItems.Add , , ("Add Item")
----[end form]----

What am I doing wrong?

Thanks in advance for any help!
- Brian

Print Listview Listitems And Columnheader
How to set the A4 paper to print the listview listitems and listview column header as lanscape or potrait?By default it print as potrait. So How to set the paper to print as lanscape if the columnheader reach the A4 limit margin size?


Code:

'Print Column Header
Dim head As ColumnHeader
Dim colColumnIndexes As Collection
Dim Idx As Long
Dim iTab As Long

Set colColumnIndexes = New Collection
iTab = 5
Printer.FontUnderline = True
'Print the column headers and load the collection of
'column indexes that will be used when printing the ListView data.
For Idx = 0 To printtext.List2.ListCount - 1
For Each head In Form5.ListView2.ColumnHeaders
If printtext.List2.List(Idx) = head.Text Then

Printer.Print Tab(iTab); printtext.List2.List(Idx);
iTab = iTab + 30
colColumnIndexes.Add head.SubItemIndex

End If
Next
Next

Printer.Print

Printer.Print vbCrLf
'Print ListItem
Dim item As ListItem
Dim strItem As String
For Each item In Form5.ListView2.ListItems
iTab = 5
For Idx = 1 To colColumnIndexes.Count
Printer.FontUnderline = False
If colColumnIndexes(Idx) = 0 Then 'this is not a subitem, so print the listitem data
strItem = item.Text
Else
strItem = item.ListSubItems(colColumnIndexes(Idx)).Text
End If
Printer.Print Tab(iTab); strItem;
iTab = iTab + 25

Next
Printer.Print
Next
Printer.EndDoc

How To Move Listitems Inside A Listview
Hi,

I have a typical scenario. I have a listview control and a up down controls. The listview is filled up using values inside a database. Now what I want is to move the listview items up and down according to up or down key pressed. Please help me.

Multiline Tooltips For Listitems In Listview
Well because it was asked to be posted here is my example on how to use multiline tooltips for individual listitems in a listview control... you need the included class module and regular module.. but as far as what you have to code... you just have to put the tooltip text in the listitems tag property as done in the example.. SIMPLE!

Hiding Listitems In ListView *RESOLVED*
Is there an easy way to hide listitems in a listview in report mode? My application loads a customer list into a listview in report mode, with checkboxes. Once the user checks all the checkboxes that apply, it'd be nice to have an option button to "show only checked items" similar to the Components selection screen in the VB IDE where you select which controls you want in the project. I don't see a property that allows this, but was wondering if anyone knows of an API that allows this. If not I can load the listitems into a collection first, then reload the listview from the collection to display them all, or remove the unchecked items to display only the selected ones.

Thanks in advance for any help.

Adding Listitems To Listview Is Slow
hiya, i'm adding listitems to a listview control (4 columns), but i'm adding over 500 listitems, and its taking about 8 seconds, during which time my app pauses. is there anyway to speed this up?

ps its coming from an access database and i dont really think i can speed up the data access or anything, its just the adding items to the list, in a loop

Organizing ListView ListItems By Color
Ok here goes: When I populate my listview based on a SQL query, certain listitems are assigned a diffrent color. That is, if a record meets certain criteria, I change the textcolor. I want to re-arrange the listitems grouped by color AFTER they have been populated. Anybody know the fastest way of doing it?


 Overspecialize and you breed in weakness.

ListView Sort Only Particular Listitems(rows)
I am working with a listview in vb6. If i want to sort the listitems i can set the sortorder and sort key,then if i set sorted = True,the listitems are sorted.
My query is to know whether there is any way in which i can sort only a particular range of listitems or rows in a listview and not all of them.

Remember Listitems Icon Position In Listview
hello everyone... is there a property i can set the position of the listitems in my listview? you know, just in windows explorer, it can remember the positions of listitems if the view is set to "Icons". hope you guys could help.

Visible Area Fill Of ListItems In ListView
When i am reading nearly 10,000 files from a location say MyDocuments and filling the listview , it is taking large time.

Is it possible to write code as how windows will handle like displaying the items of visible area and on scroll display the next set of data.

Thanks in Advance.

How To Compare 2 Listviews And Copy Listview Content To Another Listview?
Hi all. I am filling a listview with xml data as shown in code beleow. I am calling this part using timer.What i want at the end of this code to compare listview1 with listview2. If they are diffrent or if listview2 is empty then i copy content of listview1 to listview 2.Otherwise do nothing. could any one show me how i can make such compare an copy?Thanks


1 Code:
Dim objDoc As MSXML2.DOMDocument
Dim objNodelist As IXMLDOMNodeList
Dim objNode As IXMLDOMNode
Dim lvwItem As ListItem


    'load the xml document
    Set objDoc = New MSXML2.DOMDocument
    objDoc.async = False
    objDoc.Load "http://localhost/data.php"
   
    'add all the song nodes into a  nodelist
    Set objNodelist = objDoc.selectNodes("//song")
   
    'Clear the listview
    ListView1.ListItems.Clear

    'Loop through each song node and add to the list view
    For Each objNode In objNodelist
        Set lvwItem = ListView1.ListItems.Add(, , objNode.selectSingleNode("artist").Text)
        lvwItem.SubItems(1) = objNode.selectSingleNode("name").Text
        lvwItem.SubItems(2) = objNode.selectSingleNode("image").Text
        lvwItem.SubItems(3) = objNode.selectSingleNode("rating").Text
        lvwItem.SubItems(4) = objNode.selectSingleNode("songid").Text
        lvwItem.SubItems(5) = objNode.selectSingleNode("totalvotes").Text

    Next objNode

''Here i want to compare listview1 with listview2. If it is empty or diffrent if fill it
otherwise i do nothing.

Set lvwItem = Nothing
    Set objNodelist = Nothing
    Set objDoc = Nothing

[RESOLVED- ALL THANKS TO MC BRAIN]ListView Counting The Number Of ListItems
Hi All,
I know recordcount property is not there in ListView, anyways, I'm trying to add all the ListItems from a ListView in Ms Access Table, but dont know how to go about it. In ListBox I could just run recordcount and then get a do While to get it working. But in ListView how do I save the ListItems into Ms Access Table and the number of ListItems vary from 1-6...
Thanks

Listview: Weird Occurance On Set Itmx = LstViewQuery.ListItems.Add
On one of my forms i have a listview and items get added to the listview when the "add" button is clicked.
Heres the basic idea of the code

Dim itmx as listview
set itmx = listview1.listitems.add
itmx.text = cbo1.text
itmx.subitems(1) = cbo2.text
itmx.subitems(2) = cbo3.text

cbo1.text = ""
cbo2.text = ""
cbo3.text = ""

All items get added to the listview perfectly fine the very first time the add button is clicked. If itmx.text is blank then records get added in order, each addition gets added below the previous one

However, if itmx.text from the first entry contains any character, the second time the add button is selected, the second set of information gets added ABOVE the first one, when this should be below the first one.

The reason: This line of code seems to set the blank line above the first record.
set itmx = listview1.listitems.add

For example:
First time through:
cbo1.text = "test1"
cbo2.text = "test2
cbo3.text = "test3"

itmx.text = "test1"
itmx.subitem(1) = "test2"
itmx.subitem(2) = "test3"

Listview: (pipeline represents column)
line one: test1 | test2 | test 3

Second time the add button is clicked
cbo1.text = "test4"
cbo2.text = "test5"
cbo3.text = "test6"

itmx.text = "test4"
itmx.subitem(1) = "test5"
itmx.subitem(2) = "test6"

line one: test4 | test5 | test 6
line two: test1 | test2 | test 3

When it should be:

line one: test1 | test2| test3
line two: test4 | test5 | test6

Can anyone offer any suggestions as to why this occurs? Any help would be greatly appreciated.

ListView To ListView Copy
Is there a way to Copy Items from one listview to another, without going through each item?

Listview To Listview Copy
I'm looking for some sample code that shows you how to copy selected contents from one listview control to another listview control. Can anyone help me out with that?

Thanks much.

ListView &"Selecting ListItems&"
Lets say I have a ListView with 1 Column

...With 2 ListItems
"Item 1" & "Item2"

How would I be able to Select(or highlight)
"Item 1"(Or "Item 2") and then click a command button
to display which ListItem I have selected.

I know when you click off the ListView, you lose your focus.
So I will settle for having to click Or double click(If there is not an easy way to do it the first way) a ListItem to display which item I have clicked.(like in a text box or something)

Here is my Code...

Copy A Listview To Another
Hi, can anyone guide me on how to copy a ListView to another. This is my Problem, I show some textbox and when data entry push a button that data is inserting into a Listview 'A'. If someone decide not to save the new lines, I want to restore de old Listview. I was Thinking in make a clone 'B' before and then if data entry do not want to save the new data, simply copy 'B' to 'A' and keep my old data ... but I don't know how to do it.

Please hlp me. Thks.

Copy Listview
Hi
Id like to copy the content of a listviewto another listview, does somebody have an idea of the way i can do this


thanks
Mel

Copy ListView
Hi, I am trying to copy the contents of one listview (named lstActRec) to another one (name lstRecords). I thought it would be a simple task. But I'm running into problems.
I am using the code below, The only thing that happens is the first row of lstActRec gets copied to the seconed listview a bunch of times and that's it. Can anyone tell me what's wrong?


Code:
For i = 1 To frmMain.lstActRec.ListItems.Count
frmMain.lstActRec.ListItems.Item(i).Selected = True
Set lvw = frmMain.lstRecords.ListItems.Add(, , .Text)
lvw.SubItems(1) = .ListSubItems(1)
lvw.SubItems(2) = .ListSubItems(2)
lvw.SubItems(3) = .ListSubItems(3)
lvw.SubItems(4) = .ListSubItems(4)
lvw.SubItems(5) = .ListSubItems(5)
lvw.SubItems(6) = .ListSubItems(6)
lvw.SubItems(7) = .ListSubItems(7)
lvw.SubItems(8) = .ListSubItems(8)
lvw.SubItems(9) = .ListSubItems(9)

Set lvw = Nothing
Next i

ListView Copy
Hello to all,

Here is my CustomerListView

[x] John Don 102 Pearl Street
[x] Dean Harris 89 Pine Street
[ ] Sammy Davis 104 River Dale Street
[X] John Remierz 40-40 Orange county Fla 10293

<Show>

I want to click the Show button and open a popup form.
The popup form has another listview (customerDetails).
I need to copy ~~Only~~ the ones that are check in the CustomerListView to CustomerDetails Listview.

How do you copy from one listview to another. Keep in mind that I also have an ico in the CustomerListView and I need to bring that too.

I seen someone done this before but can't find the sample.
thanks for any help

Copy From Listview
Hi all!
I have a few problems with my listview. What i want to do i be able to copy the selected item and then be able to paste it some where else on the form. All i have now is basicly the popup menu with "Copy" and Paste", but i have no code behind it.
I´m guessing i should use the "ListView1.SelectedItem.Text" property somehow, but this only returns the text in the first column. I have multiple columns that are created based on user selection, so the number of columns will vary.
Also, when i left-click on the listview, the entire horizontal row of items is selected, not just the item i clicked on.
I´m thinking i should work that part out before proceeding the the copy/paste problem. Does anyonehave any suggestion?

Cheers!
Maverick



Edited by - Maverick2004 on 1/30/2005 12:08:16 PM

Listview Copy
Hi, guys!!

Can I copy all rows in a ListViewCtrl? Remember that default is select only the first colunm.


Any Help? Thanks for your help

Copy Listview Object
Hello!

It is possible to copy the listitems for one listview to another without make a cycle ?

Thanks

Listview: Copy Value In Column
Hello gurus

Situation:

Object= Listview
--------------
| Name | ID |
--------------
| John | 1 |
| Jenny | 2 |
| Joe | 3 |
| Jimmy | 5 |
| Nick | 6 |
| Susan | 7 |
--------------

What I want to do is to copy ID value from Listview's ID column and place it into a Combobox.
BUT the value that will be copy stated from selected row. For example, when I click Jenny, ID that will be copy

into Combobox are 2,3,5,6, and 7.

How to do that?

Thank you.

Select And Copy A Row From A Listview
I have this listview with a number of rows and columns or items and subitems. I want that, when I click on a row, the various subitems on that row are copied to a number of textboxes.

Copy ListView Row To Clipboard
Hi,

I thought this one should be very easy but somehow I can't figure out how to copy the content ( text and numbers in a row) of my Listview Object (ListMain.View = lvwReport, MultiSelect = True, FullRowSelect = True) to the clipboard.
I don't care if you have to click, doubleclick or use right mouseclick, Strg+C,for the row to be copied.


As you may have noticed I'm not a native English speaker and I just started programming so please be patient.

Thanks a lot in advanced.

Q

COPY/PASTE Possible In Listview?
I was wondering how to copy text from a feild in a listview on a form.
The user should be able to copy the text and paste in another textbox.

Copy Listview Text
I want to be able to copy and paste text from a listview, but I am unable to place my cursor in the listview and highlight the text to begin with. What to do?

Listview Copy To Clipboard
I searched the forum and found this code that copies all the items to the Clipboard, but only one column. My listview has 2 columns. Can someone help me alter this to copy both columns to the Clipboard? Thanks


Dim tmpString$
For i% = 1 To ListView1.ListItems.Count
tmpString$ = tmpString$ & ListView1.ListItems.Item(i%) & vbCrLf
Next
Clipboard.SetText tmpString$

How To Copy Listview Contents
I have a ListView with 7 columns of data and anywhere from 1 to 255 rows of data. I would like to be able to have the user right-click on the data and copy all of it to the clipboard. Probably would be best to have it in tab-delimited format. Any ideas? Thanks!!!

Is That Possible To Copy From Any Text Of Listview To Textbox
I'm using listview on the Userform with textbox
is that possible when I click on any text of any columns of Listview it will copy to texbox.

Is It Possible To Copy The Item From Listview To Sheet?
Is it possible to copy the item from listview to sheet?

Cut/copy Files From Listview To Explorer
pals...

this is my first post and i hope, i m not makin any mistakes...(if i do then plz guide me.)

i m coding a project for my office,,and m stuck at a point.
i m using a listview control to list files that my program searches based on certain parameters, after listing, wot i need to do is, if i press ctr+C then the file should be copied into clipboard so that if i press ctr+v in explorer, then the file should be copied in explorer. same way, if i press ctr+X then the file should be cut into clipboard... and acc...

but couldnt find it, how to do it appropriately......
got hold of certain API's,


Code:
Private Declare Function EmptyClipboard Lib "user32" () As Long
Private Declare Function OpenClipboard Lib "user32" (ByVal hWnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function GetClipboardData Lib "user32" (ByVal wFormat As Long) As Long
but i think i can make ctr+c 2 work, usin these, but how to implement ctr+X.

needed some idea's pals.....

waiting for a prompt reply...

thanx

angel

Simple Listview Copy Problem
hi, me again,

today i've built a simple listview:

Private Sub InitMyListViewSchemas()

With Myschema
.ColumnHeaders.Add , , "Schema"
.ColumnHeaders.Add , , "Mag het?"
.ColumnHeaders.Add , , "Echt?"
.ColumnHeaders(1).Width = (.Width / 4) - 100
.ColumnHeaders(2).Width = (.Width / 2) - 100
.ColumnHeaders(3).Width = (.Width / 4) - 100
.FullRowSelect = True
.GridLines = True
.HideColumnHeaders = False
.LabelEdit = lvwManual
.LabelWrap = True
.View = lvwReport
End With
End Sub

and i fill it with:

Private Sub filMyListViewSchemas()
With lvSchemas
.ListItems.Add , , "Schema 1"
.ListItems(1).SubItems(1) = "Tuurlijk meid"
.ListItems(1).SubItems(2) = "Echt waar"
End With
End Sub

this all is not a problem, and i've also built some groovy stuff to select only a simgle column etc..., but now i want to just simply select a line (all of it), and press a button (named copy) and as a result, i should have an extra line in my listview, which says:

"kopie van schema 1 Tuurlijk meid Echt waar"
and i can't get it to work! simply put: how do i copy an entire line in a listview, with the possibility to add text?

VB6 ListView Copy/Paste To Clipboard
Hello --

I have a ListView control that I would like to provide three options within my VB6 application:

1) Export listview to CSV file
2) Print listview to printer
3) Copy/Paste listview to clipboard (using tabs or CSV between columns).

I think I have a clue about #1 and #2. I'm not sure how to accomplish this for #3.

If anyone has any sample code, tutorial, or can explain how this is accomplished, it would be greatly appreciated.

Thank you

Copy Listbox Contents To Listview
Hi.

I need to copy the entire contents of a Listbox (List1) to a Listview (LvP).

The Listbox has a single column and the Listview has 2 columns.

Each entry in the Listbox is made up of two sets of information seperated by a Tab, eg, X tab Description

I need the information copied over to the Listview so that the X is in the 1st column of the Listview and the Description is in the 2nd column.


I seem to be going round in circles and not getting anywhere.

Any ideas.

Steve.

Copy Selected Listview To Listbox
How can i copy all the selected items in a multiselect listview to a listbox

Copyright © 2005-08 www.BigResource.com, All rights reserved