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




Combine 2 Listview Items Into One Listview


I have 2 listviews that have a different listitems.

ex.

LV 1 LV 2
1. A 1. B
2. C 2. D
3. E 3. F


Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?

ex.

LV 3

1. A
2. C
3. E
4. D
5. E
6. F




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Combine 2 Listview Items Into One Listview
I have 2 listviews that have a different listitems.

ex.
________________
LV 1 l LV 2 l
l l
1. A l 1. B l
2. C l 2. D l
3. E l 3. F l
_______l_________l

Is there a way to combine the 2 to another listview so that they all look like this with out doubles of matching items?

ex.
_______
LV 1 l
1. A l
2. C l
3. E l
4. D l
5. E l
6. F l
_______l

How To Combine Listview And Treeview
hi everyone,
i want to know how we can combine listview and treeview in vb.
for a example i want only one scrollbar for both
list view and treeview in a form.
if anyone of u have any idea
then plz do mail me
bye
Atul

Msg All Listview Items
hi i am wanting to display a message box for each item in a listview. the code i currently have is:

Public Sub msgALL()
Dim i As Integer
For i = 0 To lstSYS.ListItems.Count - 1
MsgBox lstSYS.SelectedItem
Next i
End Sub

this only displays the first item as the code states to display the selected item. how can i make it cycle through?

thanks

Getting Listview Items
Hi!

i would like to retrieve the item text selected (by double clicking) in a listview.

How can I do?

Thanks

sonia

Listview Add Items
Hi, I have a Listview in my project and I would like to know how can I add all the text of the listview column to specific field name in my database Access. What Can I do? This is the code to add info to my Database:


Code:
Dim db As DAO.Database
Dim rs As DAO.Recordset

Set db = OpenDatabase(App.Path & "Base de DatosPros2003.mdb")
With db Set rs = .OpenRecordset("Tratamientos Pacientes")
End With

On Error Resume Next
With rs
.AddNew
!ID = Text2.Text
!Precio = txtTotalAmount.Text
!Usuario = txtCheckedBy.Text
!Codigo = txtProdCode.Text
!Tratamiento = Listview1.WHAT CODE I NEED TO ADD HERE?
!Descuento = txtDiscount.Text
!Tratamiento = txtDescription.Text
!Cantidad_Pagada = txtCash.Text
!Numero_Cheque = txtCheckNumber.Text
!Banco = txtBank.Text
.Update
.close
MsgBox "Congratulations", vbOKOnly + vbDefaultButton1, "Pro 2003"
End With

THANKS A LOT.

Same Items In Listview
Hello... I have one problem.

I fill the listview with some standard sql query.
SELECT Name FROM ...

If there are few same names, then they are all filled down.
Now, I want this:

if there are some names that they are exatcly the same I want just first one to be writed down, then the next different name and so on...

Is this possible?

Get ListView Items From Other App's
i need to get Item texts of a ListView control that we know it's hwnd from other applications.
we can easily send LVM_GETITEMTEXT message to the listview object and retrive any item. but i want to get items of a listview in another application and when i call sendmessage in this case, my program fail and close by windows. i think this is because of memory access or something like that. may other applications doesn't have access to the memory buffer of my program.
note that i can get list count (number of items) by sending LVM_GETITEMCOUNT message and it has no problem but i can't get text of items.

here is the basic code to retrive an item in vb (it works if you call it for listview controls that exists on your program and not other windows applications)

thanks
s.serp.

--------------------------- Module LVAPI.bas

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const LVM_FIRST = &H1000 ' ListView messages
Public Const LVM_GETITEMCOUNT = (LVM_FIRST + 4)
Public Const LVM_GETITEMTEXTA = (LVM_FIRST + 45) 'unicode
Public Const LVM_GETITEMTEXTW = (LVM_FIRST + 115)

Public Type LVITEM
mask As Long
iItem As Long
iSubItem As Long
State As Long
stateMask As Long
pszText As Long 'String
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long 'for IE>3
End Type

Function GetListViewText(ByVal hwnd As Long, ByVal ItemIndex As Long) As String
' Obtain the name of the specified Item of the list view
On Error Resume Next
Dim objItem As LVITEM
Dim baBuffer(320) As Byte, n As Long
With objItem
.mask = LVIF_TEXT
.iSubItem = 0
.pszText = VarPtr(baBuffer(0))
.cchTextMax = UBound(baBuffer) - 1
End With
n = SendMessage(hwnd, LVM_GETITEMTEXTA, ItemIndex - 1, objItem) ' ItemIndex-1 is because of list is zero-based index
GetListViewText = Left$(StrConv(baBuffer, vbUnicode), n) 'convert from binary byte array to a String
End Function

Function GetListViewCount(ByVal hwnd As Long) As Long
'this simply get number of items
GetListViewCount = SendMessage(hwnd, LVM_GETITEMCOUNT, 0, ByVal 0)
End Function


---------------------- Form1

Private Sub Form_Load()

With ListView1
.View = lvwReport
.ColumnHeaders.Add Text:="Name"
.ListItems.Add Text:="John"
.ListItems.Add Text:="Kharazmi"
.ListItems.Add Text:="ABCD"
.Refresh
End With

Label1.Caption = "N = " & GetListViewCount(ListView1.hwnd)
Label2.Caption = "Item 1 = " & GetListViewText(ListView1.hwnd, 1)
Label3.Caption = "Item 3 = " & GetListViewText(ListView1.hwnd, 3)

'The Problem is that we can't call this way for ListView controls of other applications!

End Sub

Need Help In ListView Items
Hi All
i use this code to add an item to listview


VB Code:
Dim itmX As ListItemSet itmX = ListView1.ListItems.Add(, , "aaaaaaa")    itmX.SubItems(1) = Time    itmX.SubItems(2) = Date

it add new item in the last row
how to add item in order newst item is in first row


thanx

Items In A ListView
I have a combobox which acts as a Lookup table, a command button and a ListView. My aim is that when i select an item from the combo, on clicking the command button, the selected item from the combo gets listed in the ListView. The code for filling the combo is :
VB Code:
Dim strSQL As String    'Declare the variables we need                   strSQL = "SELECT movieId, title FROM movieInfo"  Set rsMovie = New ADODB.Recordset         rsMovie.Open strSQL, cnAddMovie, adOpenForwardOnly, adLockReadOnly, adCmdText    With cboTitle        .Clear            Do While Not rsMovie.EOF        .AddItem rsMovie.Fields("title").Value        .ItemData(.NewIndex) = rsMovie.Fields("movieId").Value          rsMovie.MoveNext    Loop      End With   rsMovie.Close  Set rsMovie = Nothing


BUT now when the selected item is listed in the ListView, I want the following code executed.

VB Code:
'strSQL = "SELECT movieInfo.movieId, movieInfo.title, MediaType.StrKey, MediaType.DefRentPricePerDay, MediaType.DefRentPeriodInDays FROM movieInfo INNER JOIN MediaType ON movieInfo.media_catId = MediaType.media_catId WHERE movieId = " & cboTitle.ItemData(cboTitle.ListIndex)  


So that in the ListView, I have columnsheaders showing Movie title, Format, rentPrice etc

How can i do that?

Listview Max Items
Can someone please tell me what is the maximum number of items in the list with Listview?

My program searches a database with thousands of records and reports errors and I would like to be able to list them on the screen so the end user can review.(Printing them out is another story) A listbox runs out at about 32k items.
I would only need 4 colums in the listview.
If anyone has any ideas on what or how I can do this , I am all ears...

Thanks in Advance

Trent

Get Listview Items
Is it possible to save all the items in another apps listview?

Listview Items
How do I give items in a listview a tag?

Getting Sum Of Items In Listview......
Ok, I got a response to a question similar to this before, but for some reason, I couldn't even modify the code to work, and kept getting an object required error. Maybe it had something to do with my use of the listview control Anyway, I'll be more specific this time. Here goes.

Listview2:

In the main column is text, and in subitem1 column is a number (i.e 2:30)

What I want to do is on a command1_click() get the sum of all the numbers in listview2 subitem1, and set that = to sum

Then let listview3.listitems.add SUM


Hope that makes sense. Anway since there is a ":" in the number, it must currently be formatted as a string and not an integer right? So, what do I need to do to total up all of these numbers? Any help is greatly appreciated.

Listview Items....
Hey peops, I was wondering if there was anyone out there that could tell me how to disable editing within a listview's columns...What I'm doing is connecting to an Oracle DB and pulling data and then putting that recordset data onto my listview so i can view them like a spreadsheet (obviously). The problem is that when i click on an item and hold down the mouse button long enough, I'm able to edit the first column...I want to disable this ability. Basically i want none of the recordset data to be renamed or changed, but the items can be selected...thanks in advance

Add Items To ListView?
I have the code below which puts two column headers at the top of my ListView control, (Title) and (Description). . .


Code:

Private Sub Form_Load()

Me.ListView1.View = lvwReport

Me.ListView1.ColumnHeaders.Clear
Me.ListView1.ColumnHeaders.Add , , "Title", ListView1.Width / 2
Me.ListView1.ColumnHeaders.Add , , "Description", ListView1.Width / 2
End Sub



Can anyone show me the code I can add to this that will add one item in the list view control with the text (Item Title) under the ‘Title’ column and (Item Description) under the ‘Description’ column?


.

Moving Through Items In A Listview
Am I being a complete , or what? I'm trying to move through the items in a listview, so that I can insert the entries one-by-one in to DB - ie each item in the listview represents a new record in a DB table.

Now, I would have expected (as with all things VB) this to be quite straight forward. Something along the lines:

ListView1.selecteditem.movenext

I know this a bit hopeful, but I can't believe there's no way to incrementally move through all the items.

I've been through MSDN and searched this entire forum for a similar thing but I cant find anything.

I must be missing something really obvious here!

Highlighting Items In Listview...
I have this small application that has a listview wherein it gets populated by database records. My DB table is arranged alphabetically so it will also be arranged in the listview as well. But I'm haveing trouble displaying/highlighting the last item that was entered in the table so the user will have to scroll through the whole listview to see if what they entered did go in since the table is arranged alphabetically. The display type of my listview is in lvwReport by the way. Is there anyway I can do this?

Listview Items To Excel...
I was just wondering, is it possible to export the listview items to excel? If so, would it also be possible to export the selected items only?

ListView Adding Items.
Code:
Private Sub Form_Load()

With ListView1
.ColumnHeaders.Add Text:="Server"
.ColumnHeaders.Add Text:="Ram"
.ColumnHeaders.Add Text:="CPU"
.ColumnHeaders.Add Text:="C:"
.ColumnHeaders.Add Text:="Ping"
.View = lvwReport
End With



End Sub
i have this code to give the listview1 5 diffrent columns.

can someone give me the code that when command1 is clicked, it will add a row underneath the columns in this order:

server1
ram1
cpu1
c:1
ping1

just so i know how to do this.

Swap Items In Listview
Hello I have a scenario here.
I have a Listview and two command butons (up and down)
Initial Listview Items

A text1 text1
B text2 text2
C text3 text3 - Selected

now when the Up button this is what will happen

A text1 text1
C text3 text3 - Selected
B text2 text2

Hope someone here help me.

Thanks

Search Through ListView Items
pls can anyone show me how to search through listview items

for example - find a specific text in a ListView

Adding N Items Into ListView
I am using following code to add records read from a text file into a ListView object.


Code:
Dim S
Dim SP
Dim i
Dim LItem As ListItem

i = 1
Open App.Path & "dataspdates.txt" For Input As #1

Do While Not EOF(1)
Line Input #1, S
SP = Split(S, "+", , vbTextCompare)

Set LItem = ListView1.ListItems.Add(, , SP(0))
LItem.SubItems(1) = SP(1)
i = i + 1
Loop
Close #1
My ListView Control has just two columns, and the text file contains records like:

3/10/04+Mr.D Birthday
6/1/04+Mr.C.Anniversary

In the above code, SP will store the splitted line read from the file. The problem is that the above code displays an error "Subscript out of range", at the line starting with "Set LItem".
How to keep adding records to ListView till EOF.

Listview Selected Items
hey i was wondering if it is possible to retrieve a collection of selected items from a listview which has multiselect set to true

(not checked, but selected)

i was hoping i could do something like this ...


Code:
dim li as listitem
for each li in listview1.selecteditems
' do something
next li
... but it doesn't appear to be so easy

any hints ?

thanks,

huby.

Please Help {listview Items To Textbox}
I want to add all the data from the first column to a textbox. I was thinking of this:

For i = 1 To ListView1.ListItems.Count
Text1.Text = ListView1.ListItems(i)

But this only gets the last item. So I thought how about if I have i and add 1 to it each time after putting the next item into the textbox and if there is no more data it would stop.

I don't know how to do this, can someone please help?

Listview Sort Items
Hi,

how can I move Items in a ListView with an up and down button?

Navigate Through ListView Items...
I have a listview control on a form, and I want to be able to navigate through rows with Up/Down buttons, I can't figure out how this is achieved atall, I wish to do similar to "List1.ListIndex = List1.ListIndex + 1" if i was using a listbox control... But i cant find the appropriate commands for a listview control... any help would be greatly appreciated
Thanks
Matt

Searching Listview Items
anyone know how to search listview items?

Listview Non-moveable Items
How do you set the items in a listview box to be non draggable?

Adding Items To A Listview
I have searched thru the forum, just cant find what im looking for. this is the layout of my listview

Fkey | Action


I wish to add items to the fkey column, and also text to the action clolumn.
listview1.ListItems.Add.Text = "blah" <-- i tried that, but that only goes in Fkey...

How would i do this please,

Thanks

Coloring Listview Items
Could someone simplify this code:

Private Sub Command4_Click()
Dim i As Integer
1) ListView1.SelectedItem.ForeColor = vbRed
For i = 1 To 4
2) lista.ListSubItems.Item(i).ForeColor = vbRed
Next
End Sub

lista is a listview object

It does work but it seems like it should could be easier made.
I´m a little lost with all the subitems, listitems, item, selected, selecteditem etc.

1) just colors the first column in the row.
2) colors the next columns (the subitems).

so the code colors a row, and it works but it looks stupid (I think).

Removing Items From Another ListView
I have 2 Listviews on separate forms.
I can add the checked item from one listview to the other ok.
But i am having trouble removing the item from the 2nd listview when i uncheck it on the 1st listview as i am having trouble determining what the index of the item in the second list view is.

So basically i want to ba able to add and remove items to/from a listview by checking and unchecking a listview on a seperate form.

Dazza.

Print Only 15 Items From Listview.
Aight, I got this:


Code:
Dim i As Integer
Close #1
Open (App.Path & "asdf.txt") For Output As #1
For i = 1 To Form1.ChannelList.ListItems.Count
Print #1, Form1.ChannelList.ListItems.Item(i)
Next i
Close #1

That works fine, but I cant figure out how to make it print only 15 items.

Help?

Edit Items In Listview
I have a form that has a listview control on it with 3 columns. These columns are being populated from 3 text boxes and a command button.
This part works fine.

But I would like to select an item entered into the listview and have the items and subitems populate the text boxes in the event I make a mistake on entering data. I have tried:

Code:
lvwhunt.selecteditem.key
to obtain the item key and populate the text boxes in the reverse order that I populated the listview.
Here is my code for populating the listview from the textboxes:

Code:
Private Sub cmdAddExt_Click()
On Error GoTo errhandler

dHNum = txtExtNum.Text
dHPair = txtPairNum.Text
sHName = txtExtName.Text

iHItems = iHItems + 1
lvwHunt.ListItems.Add iHItems, , dHNum
lvwHunt.ListItems(iHItems).SubItems(1) = dHPair
lvwHunt.ListItems(iHItems).SubItems(2) = sHName
lvwHunt.Refresh

dHNum = vbNull
dHPair = vbNull
sHName = vbNull
txtExtNum.Text = ""
txtPairNum.Text = ""
txtExtName.Text = ""
frmHunt.Repaint
txtExtNum.SetFocus

Exit Sub
errhandler:
Debug.Print Err.Number & " " & Err.Description
Err.Clear
Resume Next

End Sub

Hope this makes sense, thanks in advance for your assistence.

Bart

Selecting Listview Items
I am having trouble moving to the next item in a listview automatically. I am trying to create option buttons and put the text from the listview to the option button to have users select with Name they want. I do not know how to select the next item below or above the selected item in the listview? Any sugestions? Thanks

Editing ListView Sub Items
I have a listview component which is populated and fine. i need to be able to edit a single items subitem in the listview,cant get it sorted?

Any thoughts or ideas on this?
Thanks

Hide Items In Listview
Hello...

I have attached some pic ....

I fill the listview like this:


Code:
'SQL...QUERY

Do Until Tabela.EOF

If Not IsNull(!Voznik_sif) Then
lstPlanIzpis.ListItems.Add.Text = !Voznik_sif
End If
If Not IsNull(!PriimekIme) Then
lstPlanIzpis.ListItems(x + 1).SubItems(1) = !PriimekIme
End If
If Not IsNull(!UlicaSt) Then
lstPlanIzpis.ListItems(x + 1).SubItems(2) = !UlicaSt
End If
If Not IsNull(!Kraj) Then
lstPlanIzpis.ListItems(x + 1).SubItems(3) = !Kraj
End If
If Not IsNull(!Telefon) Then
lstPlanIzpis.ListItems(x + 1).SubItems(4) = !Telefon
End If
If Not IsNull(!Ura) Then
lstPlanIzpis.ListItems(x + 1).SubItems(5) = !Ura
End If
If Not IsNull(!Namen_sif) Then
lstPlanIzpis.ListItems(x + 1).SubItems(6) = !Namen_sif
End If
If Not IsNull(!Nacin_sif) Then
lstPlanIzpis.ListItems(x + 1).SubItems(7) = !Nacin_sif
End If
If Not IsNull(!Opombe) Then
lstPlanIzpis.ListItems(x + 1).SubItems(8) = !Opombe
End If
If Not IsNull(!KoncnoStanje) Then
lstPlanIzpis.ListItems(x + 1).SubItems(9) = !KoncnoStanje
End If
x = x + 1
.MoveNext
Loop
End With

Now I want to hide duplicate names in listview (see att. photo).
Any idea?

Saving Listview Items.
Hi guyz!can you please give an idea of saving item in listview in a database? I have populate 3 items in listview and I want to save that items in database. 3 items corresponds to 3 fields in my database. thanks!

Inserting Items To A ListView
I understand how to insert an item into the first column of a ListView control, but how do I insert an item to a second, third, etc., column?

Edit:
If it helps, I have the ListView in Report view.

Locating Items In Listview
Hi

I am trying to use the API call of "Sendmessage" to locate a value in a listview but no success. I have used it wil Textbox, combobox, and listbox , works fine but seems no too interested in listview. Hence there may some other call, or anyone else has a clue about doing in incremental search on a listview (on the indexed field ofcourse).

Regards

Yamin

Prevent Items From Getting Put In A Listview?
Hey guys I have a listview called report,

is there a way to prevent the item called "End of Search" From being added to it?

Thank you.

Check Items In ListView?
When an item joins the ListView, how do I make it so it automatically checks it without clicking a button?

Add A Lot Of Items To Listview *quickly*
I am running a loop through about 500,000+ items and add the items to an array. I would like to add the items to a ListView at the same time, but the problem is it takes WAY too long. It also takes exponentially longer because I have a label that displays the percentage that is done and because of that I need to put a "DoEvents" statement. The DoEvents statement slows it down a LOTT.

Is there any way around this.. to make the entire process much quicker?

Move Items In The Listview
I am refer the following thread below to move the items in the listview.

http://www.vbforums.com/showthread.p...items+listview

When there is not items in the listview, I click the button, I got the error message. and the error message point at
strCol1 = ListView1.SelectedItem

So How to solve it?


Code:
Dim itmX As ListItem
Dim strCol1 As String
Dim strCol2 As String
Dim lngIndex As Long
strCol1 = ListView1.SelectedItem
strCol2 = ListView1.SelectedItem.SubItems(1)
lngIndex = ListView1.SelectedItem.Index
ListView1.ListItems.Remove (lngIndex)
If lngIndex = ListView1.ListItems.Count + 1 Then
lngIndex = 0
End If
Set itmX = ListView1.ListItems.Add(lngIndex + 1, , strCol1)
itmX.SubItems(1) = strCol2

ListView1.ListItems(lngIndex + 1).selected = True

Child Items In A Listview
Hello, I found the project below that is a Listview with child items in the first column (like a treeview).

When you double-click on an item it expands and adds 10 child items. What I'd like to do is add child items without expanding, so the child items are not visible, but still can be used. After playing around with it for an hour I haven't been able to do it.

Is there anybody who wants to take a look at the code and tell me if it's possible to add child items in the first column without expanding and making them visible?

Thank you.

Re-arrange An Items In LISTVIEW?
Hi,

The app have a LISTVIEW with multi-columns in it, I want to let the user move the selected item up and down to whatever position they want to go.

Preferred to create two "UP" and "DOWN" button on the form, so the user just hightlighted the item in the listview then move it up and down.

No need to handle select multiple-items

Any simple will be great.

Thanks!

Editable Listview Sub Items?
Hi everyone.

i have a class module code that edits every subitem from a listview with a textbox, and what i´m trying to do with that code is pass a value from another form textbox to the editable listview textbox value.

How can i do this?

thanks

Listview Items Dbl Click
Hi,

i can get listindex of a lstbox but how to do the same when i dbl click items in a listview control since i got columns

Selecting Listview Items
Hi, am working on a movie check-in form. This form displays all movies that have been checked out by a particular customer. The Listview control is populated by selecting the customerID from the cboCutomers control. Assuming that a customer has three movies checked out but instead of returning/checking in all the 3 movies, he wants to return only on of the moves listed. How can I ensure that the selected movie is the one that is checked out when I click on the check-in command button?

Thanks

Swap Items In Listview
hello i was just wondering if the solution given to me yesterday concerning Listboxes will apply to Listview considering that a listview has more than one column. here again is the scenario..

I have a Listview and two command butons (up and down)
Initial Listview Items

A text1 text1
B text2 text2
C text3 text3 - Selected

now when the Up button this is what will happen

A text1 text1
C text3 text3 - Selected
B text2 text2

Hope someone here help me, actually my problem with listbox is solved but i have a listview that need the same functionality.

Thanks.

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