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




Show Multiple Items In Listview Taken From Database


How would I show multiple items from an Access database in a listview?

Example: Let's say my database looks like this:

Sender Subject Date
me@isp.com Some Subject 1-13-00 7:59AM
you@otherisp.com Some other subject 7-30-01 8:00AM

I want to load both items into a listview. My current procedure only loads one item at a time. Here is the procedure:


Code:
Dim Recordset As ADODB.Recordset
Select Case Node.Text
Case "Trash"
If Recordset.EOF = True Then Exit Sub
lvwMail.ListItems.Clear
With lvwMail.ListItems.Add(, , Recordset!Sender)
.SubItems(1) = Recordset!Subject
.SubItems(2) = Recordset!Date
End With
End Select




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Show Icons Against ListView Items
Hi

Can I show items in a ListView with icons becide each item. I would like that icon to describe the item. Do I have to use a different control ?

Thanks
Robert

Add Items To A Listview Multiple Columns
Hi... I have a listview with 3 columns... how can i add items to the second and the third column? i know it's a stupid question but i can't solve it


Thanks in advance

simons

Moving Multiple Listview Items Up Or Down At Once
Hi, does anybody know how to move multiple selected listview items up or down at once?

I found the subs below, but they only move one item up or down, even if I have selected multiple items.

Thanks.


vb Code:
Private Enum menmDirections    MoveUp = 1    MoveDown = 2End Enum Private Sub MoveItem(ByVal penmDirection As menmDirections)Dim lvwItem     As ListItemDim lvwNew      As ListItemDim lvwSubItem  As ListSubItemDim lngIndex    As Long    Set lvwItem = lstView.SelectedItem    If Not (lvwItem Is Nothing) Then        If penmDirection = MoveUp Then            lngIndex = lvwItem.Index + 2        ElseIf penmDirection = MoveDown Then            lngIndex = lvwItem.Index - 1        End If        If lngIndex > 0 And lngIndex <= lstView.ListItems.Count + 1 Then            Set lvwNew = lstView.ListItems.Add(lngIndex, , lvwItem.Text)            For Each lvwSubItem In lvwItem.ListSubItems                lvwNew.ListSubItems.Add , lvwSubItem.Key, lvwSubItem.Text, lvwSubItem.ReportIcon, lvwSubItem.ToolTipText            Next lvwSubItem            lvwNew.Selected = True            Set lvwNew = Nothing            lstView.ListItems.Remove lvwItem.Index        End If        Set lvwItem = Nothing    End IfEnd Sub



vb Code:
Private Sub MoveUp(lv As ListView)    Dim itm As ListItem, itmNew As ListItem, i As Long    If lv.SelectedItem.Index > 1 Then        Set itm = lv.SelectedItem        Set itmNew = lv.ListItems.Add(itm.Index - 1, , itm.Text, itm.Icon, itm.SmallIcon)        For i = 1 To itm.ListSubItems.Count            With itm.ListSubItems(i)                Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText)            End With        Next        lv.ListItems.Remove itm.Index        itmNew.Selected = True        lv.SetFocus    End IfEnd Sub Private Sub MoveDown(lv As ListView)    Dim itm As ListItem, itmNew As ListItem, i As Long    If lv.SelectedItem.Index < lv.ListItems.Count Then        Set itm = lv.SelectedItem        Set itmNew = lv.ListItems.Add(itm.Index + 2, , itm.Text, itm.Icon, itm.SmallIcon)        For i = 1 To itm.ListSubItems.Count            With itm.ListSubItems(i)                Call itmNew.ListSubItems.Add(, .Key, .Text, .ReportIcon, .ToolTipText)            End With        Next        lv.ListItems.Remove itm.Index        itmNew.Selected = True        lv.SetFocus    End IfEnd Sub

Listview - DragDrop Multiple Items
I have the following code that successfully will drag & drop one item at a time, but doesn't work all the time if multiple rows are selected?
When I start to drag, sometimes nothing happens.

Anybody point me in the right direction please?


Code:
Private Sub lvwSelected_OLEDragDrop(Data As MSComctlLib.DataObject, Effect As Long, Button As Integer, Shift As Integer, x As Single, y As Single)
On Error GoTo ErrTrap

Dim i As Long
Dim lvwItem As ListItem

For i = 1 To lvwSource.ListItems.Count
If lvwSource.ListItems(i).Selected = True Then
Set lvwItem = lvwSelected.ListItems.Add(, , lvwSource.ListItems(i).Text)
lvwItem.SubItems(1) = lvwSource.ListItems(i).SubItems(1)
lvwItem.SubItems(2) = lvwSource.ListItems(i).SubItems(2)
'remove original item
lvwSource.ListItems.Remove i
End If
Next

Also, when dragging multiple items across, and removing the original item, I now get an error because the ListItem.Count is now out of bounds.
How would I handle this?
Would I add 1 to the value of 'i' before the next loop?

Multiple Selected Items In A Listview
Hello, how can I find out how many selected items there are in a listview?

I'm showing a popup menu when the user right-clicks on an item, but I need to know if only 1 item is selected, so I can disable a menu option.

I've tried this, but it doesn't work.


VB Code:
If ListView.SelectedItem < 2 Then mnuCopyMultiple.Enabled = False

Dragging Multiple Items From A Listview
i have some code to let users drag an item from a listview onto a treeview node, which works fine, but now i want to let them drag multiple items.

the problem is that when then select a bunch of items, then drag them to the treeview, it leaves only the last item they clicked on selected (as if they selected them, then just left-clicked one of them). is there a way to keep them all selected?

also, just out of interest, is there a way to make the drag icon include some text from each selected listview item along with an icon (like when you drag multiple files in windows explorer)?

thanks for any help

Remove Multiple Items From ListView
I've got a ListView control with the MultiSelect property set to True and would like to remove all of the selected items only. I've looked at some of the threads concerning this issue but am still having trouble. I can remove a single selected item but not all of the selected items. My code is as follows:


Code:
Private Sub cmdRemove_Click()

Dim I As Integer

For I = 1 To lstPlot.ListItems.Count
If lstPlot.ListItems(I).Selected = True Then
lstPlot.ListItems.Remove (I)
End If
Next I

End Sub


What am I missing?

Thanks for your help!

Multiple Select Items In Listview
im having a problem in listview. ther ar 2 listviews for Excel and server. the user will select fields in th excel lisview he want to upload in server lisview. it upload a field if the user only select 1 field. but if it highlights many fields it only copy the lastselected fields the other fields highlighted dont work. heres my code:

j = LVExcel.ListItems.Count
 For i = j To 1 Step -1
  If LVExcel.ListItems(i).Selected = True And LVDatabase.ListItems(i).Selected = True Then
        Set rs1 = New ADODB.Recordset
        destinationtble = "select * from [user]"
        rs1.Open destinationtble, gcn, adOpenKeyset, adLockOptimistic
           Do While Not RS.EOF
              rs1.AddNew
              rs1.Fields(LVDatabase.SelectedItem.Text) = RS.Fields(LVExcel.SelectedItem.Text)
              rs1.Update
              RS.MoveNext
           Loop
          Set RS = Nothing
  End If
next i

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Drag Multiple Items From Listview To Treeview
Does anyone have some good sample code for how to
drag multiple listviewitems to an treeview?!

I cant figure it out...

Regards

Peter

How To Move Multiple Selected Items To New ListView
I have 2 ListView Controls. I need to move multiple selected items from ListView1 to ListView2.

How would I go about doing this?

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Please Help Me With Drag-n-Drop Of Multiple Items From One Listview To Another.
Hello!

I'm facing a problem with Listview Drog and Drop of multiple items from one listview to another listview. When I try to Drag only one single item, the item is dragged without any problem. However, when the multiple selected items are dragged, the Listview on which the items are dropped, receives information about only one item and not all selected items. The item, about which the information is received, is the same on which I click and hold mouse to start drag action. So, it looks like even though multiple items are selected in a listview, while executing the Drag-Drop action, listview treats it as single item selected!

Is this a default behavior of Listview or am I missing/doing anything wrong? Any work-around for this (seems like default) behavior of Listview? I searched for it and got a code example at http://btmtz.mvps.org/listview/ where the author has demonstrated Drag-Drop of multiple items. However, the code is specifically restricted to re-arranging items within same Listview and the information is transported via Drag-Drop to another Listview, upon which the items are dropped.

To help you all to get a better insight of my problem, I have attached a Demo of Listview Drag-n-Drop. Please see the project and you will see that when one item is dragged from left side Listview to right side Listview, no problem for VB to allow me to do it! However, when you select multiple items in left side Listview and try dragging those to right side Listview, only one item is dragged. Please let me know if I'm doing anything wrong here and please help me to get this stuff to work!

Waiting for your valuable reply ...

Regards,

Ruturaj.

Insert Multiple Items From Listbox To Database
hi i have a listbox where the style is checkbox, now i want to save the items that the user checked in the listbox to my database.. i am using MSSQL Server 2000 and here is my code.. i need help badly

For i = 1 To phaselist.ListCount - 1
If (phaselist.Selected(i) = True) Then
stmt2 = "Insert into savedphase (phaseID, projectID,
phaseName) VALUES ('"
stmt2 = stmt2 & phaselist.ItemData(i) & "', '"
stmt2 = stmt2 & Label4.Caption & "', '"
stmt2 = stmt2 & phaselist.Text & "');"

insertRecord (stmt2)
MsgBox "Success", vbOKOnly, "Good"

Exit Sub

End If
Next i


this code is located in the save button that i have created please help anyone..

Listing Multiple Database Items In One Combo Box
I'm looking to link a combobox with a database so that i can display all entries from a particular field of the database. How can i do this???

Inserting ListView Items Into The Database
Hi!

I have 3 short questions that i hope you guyz can help me with

I have a few text fields that enters names, occupations and telephone numbers into a ListView control when the user clicks add...

how do I loop the list to enter each line of data into the database...

and also... how do you remove a specific line in a listview...
i've tried this
SocialFamilyList.ListItems.Remove(Index)
but this doesn't work

what's am i doing wrong...

and how do select a whole row when you click on the details in the listview control

Thank You For Your Time

~JoHn~

Saving ListView Items To Database
Hi this is Amar,

I am new to vb.. I wanna save ListView items to database and I have to retrieve from data base again. Please tell me how to solve this .. for MSAccess as database...
If anybody having the code... please send it to me...

I am very thankful to you..


Regards,
Amarendra.

Removing Items From Listview And The Database As Well..
have a listview that allows the user to remove the items.. items in listview is retrieved from the database.. wat i'm doin is, when i right-click on the item in the list view, a menu pops up and if the user clicks on remove, will remove the item from the list, and not the database..

so lets say, there are 10 items in the listview, retrieved from the database, user removes 3.. how can i update my database in the sense that there will be 7 records left.. any idea?

i juz use this to remove from the listview..


VB Code:
lvwData.ListItems.Remove (lvwitem.Index)



thanks in advance

Recovering Checked Items In A ListView From A Database
I have been working on a program that stores ListView items in a random access file. I have been trying to store the items in such a way, that when I populate the ListView from the file it restore those items that were checked in the checkbox. It hasn't worked well. It lists the items that were checked twice, for some reason, one checked and one not, and omits the others.
Any suggestions?

Save Items From Listview To Access Database
I m doing my project of invoice management.......i gotta problem...............
How could I save the listview items in access database(listview is in report mode).....?
Suppose i have column called "Amount".........how could I sum up all the items in column named "Amount"
I m using visual basic 6.

Sabin Kumar Chhetri

Edited by - saracjl on 3/17/2005 5:46:12 AM

Show Related Access Database Fields From Multiple Tables
I have a form with 3 datagrids I am trying to show ONLY related records??

Saving Listview Items Into Access Database....[Urgent]
I have two textbox and one listview in the form(in report mode). List view contains five columns, say, SerialNumber, Products, ProductDescription, Unitprice and Amount. Listview contains many subitems. One textbox contains Customer's Name and Other Contains the Invoice number. How to save all the listview subitems in access database for corresponding customer name and invoice number. Invoice Number is the unique one in the database.??

Looking for the help,
Saracjl
Thankx.

How Can I Use A Listview,i Want To Show Large Image And Details By Database?
how can i use a listview,i want to show large image and details by database?

In Listview I Would Like Use Database And All Data Show In List Columnheader Wise
in listview i would like use database and all data show in list columnheader wise ...?

Delete Multiple Item From Database Through Listview
hi all

plzzzz help me,i want to delete multiple item from database through listview with checkbox property is true.If possible then plzzzzz give me some code for that.

thankx in advancce

Show More Items In Combobox
Hello there,

Is there a possibility to show more items when you click on a combobox?

Now if I click the combobox it shows the first 8 items. Can it be extended so that it shows more items at a time (eg. 15)?


Thanks in advance!

Christophe

Hey Yall I Am Trying To Show Items On Call
i am using the visible properties. I can make the opt buttons appear when clicked on cmd button but can't get the visible items togo invisible again???

here is my code:
vb Code:
Private Sub cmdIndiana_Click()If cmdIndiana = True ThenoptLou.Visible = TrueElsecmdIndiana = FalseoptLou.Visible = FalseEnd IfEnd Sub Private Sub cmdKentucky_Click()If cmdKentucky = True ThenoptYes.Visible = TrueoptSlo.Visible = TrueoptAlf.Visible = TrueoptMca.Visible = TrueElseEnd IfEnd Sub

any help with be accepted with gracious innovate apperication!

Hide/Show Desktop Items
hey..using command buttons how can i hide/show desktop items?

How To Show The Items In Different Colors In Combobox?
Can anyone tell me how to show the items(text) in different colors in combobox?

Dropdown Combobox...Show More Items?
How do you get a combo box to display more items?
Anyone got the API code for it?

Combobox...dont Show Existing Items...
Hi there,

I created a combobox... that I fill with values from textfiles...

so far so good...

Just one thing...

I dont want VB to show two or more of the SAME items....

Is there an easy way to do this??

I can do it with storing the values in an array... so i can check the retrieved values from the textfile with already existing values... but aint there a much more easier way... maybe a setting for the combobox??

tnx anyway...

How To Let Combo Box Show Flag To Those Longer Items?
My app has a combo box, but the width is limited. But there's some item's content is longer than combo box's width. How could i let the combobox show a flag something to let user know the whole item's content??

Thanks!

Best Regards,

Kevin Shen

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

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

ComboBox1 Items Link To Computer File, Then Show In RichTextBox'TextBox
I would like to:
1) Make a file that would be read off of the computer.
2) Have my ComboBox that has a drop down item that says "Apples."
3) Have the selected item "Apples" get the file Apples.txt.
4) Load the file into RichtextBox/TextBox.
I have seen every kind of example but none address this which is probably as old as when VB was in infancy and all of the "old timers" know this.
Insert whiney/confused face here ad lib.
email@removed

Multiple Items In A Collection
Hello all,

I've got a (simple?) question that has me flabberghasted.
I'm trying to program a simple pacman clone.


The 'Maze' object has a collection of ghosts, that get filled like this:

For col = 0 To 1 'create some ghosts for testing
For row = 0 To 1

Set Ghost = New clsGhost

Ghost.PosX = col * 14 * 48
Ghost.PosY = row * 8 * 48
Ghost.Speed = 20 * row + 40 * col

Ghosts.Add Ghost

Next row
Next col


If the ghost is to walk around in the maze, it has to know about possible
directions, so the ghost can raise an event to its parent (the maze):

RaiseEvent GetDirection( iPosX SQUARE_WIDTH + 1, _
iPosY SQUARE_HEIGHT, _
MazeDir)


Now, if I create only ONE ghost, then it will run happily around the maze
However, creating MORE ghosts causes the program to skip the 'RaiseEvent' instruction. ( detected during single stepping)

How can I make the 'RaiseEvent' instruction work for multiple instances of the ghost class?

TIA,
Alvatrus

Multiple Listbox Items
I have a standard listbox that instead of only one item per line I have 3 items per line such as: Quantity, ItemNum, Price. I want to add these items to their matching columns in my database of quantity, ItemNum, and Price.

Is there a column property of the listbox that I can use to extract the Items individually?


rs is my recordset

Do while rs.Eof = False
list1.addnew = rs!Quantity
Loop

This only gets one item per line.

Searching For Multiple Items
is there a way to search for more than one item at a time?

ex text

i have a red fox
i own a red car
i have six blue coats

and my search terms are: car and blue

result

i own a red car
i have six blue coats

this might be a pretty dumb ?, but then i am not a code guru

Parse Multiple Items; Help!
I have another problem, I want to be able to parse multiple userID's from a page of online users, the code I want to get between is:

Code:


Code:
_vchat_174375447'


The userID being 174375447.

I used:


Code:
Dim StrPage As String
StrPage = Inet1.OpenURL("http://www.stickam.com/whosLive.do?listType=live")

StrToken = GetBetween(1, StrPage, _
"vchat_", "'", vbTextCompare)

lstGen.AddItem (StrToken)


The code parses the string of text correctly, but my situation is that I have more than one userID in a page. So I don't need it stop after finding one, I need it to find one userID, add it to a listbox, then move onto another userID in the data, then add it to a listbox and so on. In advance of acknowledgment, each userID has the same beginning and ending:


Code:
_vchat_userID'


Thank you,
mikeyy.

Lists And Getting Rid Of Multiple Items
Hi,

Is there any way to remove multiple items for a list. For example, the list:

A
H
A
A
K

Is there any way I could just turn it into:

A
H
K

...and remove the extra A's. Thanks.

Multiple Items Ina TEXTBOX
Hello there, is there any way where we can add items to a text box instead of a combo box... Currently I am retrieving a list of items say customer names into a combo box.. Instead of a combo box can we add multiple items into a text box....ANY SOLUTIONS ?????

Multiple Items On Same Invoice
Hello,

I am developing an order tracking system for an organisation which repairs printers, monitors and other computer parts. Each Invoice generated should have entered multiple items like printers, monitors or others on it. How do i proceed ? I mean what controls in vb should i use so that multiple items can be choosen for same invoice id ?

Can anybody help me ? Please....

Ashish Kamat

Add Items To Multiple Forms
Hello,

I have two forms with comboboxes. These comboboxes have the same items. Is there an easy way to fill these comboboxes with a single routine?

I now fill the two comboboxes with two seperate routines

Sub FillNewUserForm
frmNewUser.cmbLocation.AddItem "Amsterdam"
frmNewUser.cmbLocation.AddItem "Utrecht"
frmNewUser.cmbLocation.AddItem "Rotterdam"
End Sub

Sub FillChangeUserForm
frmChangeUser.cmbLocation.AddItem "Amsterdam"
frmChangeUser.cmbLocation.AddItem "Utrecht"
frmChangeUser.cmbLocation.AddItem "Rotterdam"
End Sub

How To Select Multiple Items From A List Box To Another?
Hi guys..

I'd like to know how to select multiple items from a main list box to another list box? I've enabled the select extended on the main list box? Also, how do i remove multiple?
Currently, I can only move one item at a time.

Thanks!!

Regards
Vivien

Add Items In Multiple Columns Of A Listbox
Does anyone know how to add items into 2 columns of a listbox?
I have 2 columns but when I do this:
lstTopic.AddItem rs.Fields(0)
the value is added into the first column. How do i add an other value in the second column?
Thanks!!

Remove Multiple Items From A Listbox
How can I remove multiple items from a listbox?

I have tried this, but it won't work....


Code:
Dim i As Integer

For i = 0 To Me.lstFiles.ListCount - 1
If Me.lstFiles.Selected(i) = True Then
Me.lstFiles.RemoveItem Me.lstFiles.List(i)
End If
Next i

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