473,324 Members | 2,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,324 developers and data experts.

Adding Items to Listview Manually.

debasisdas
8,127 Expert 4TB
Select Microsoft windows common controls 6.0 (SP6) from components
Add a ListView control to the form.
Add 2 ImageList controls to the form.
Add some bitmaps to both the imagelist.
Set the name of image list to the Normal and small icon Image List from the Image lists tab in property pallet of the Listview control.
Add a combobox .

Add this sample code to the form
=============================
Expand|Select|Wrap|Line Numbers
  1. Private Sub Combo1_Click()
  2. LV1.View = Combo1.ListIndex
  3. End Sub
  4.  
  5. Private Sub Form_Load()
  6. Dim C As ColumnHeader
  7. Dim i As Integer
  8. For i = 1 To 4
  9. Set C = LV1.ColumnHeaders.Add()
  10. C.Text = "Field" & i
  11. C.Width = LV1.Width / 4
  12. Next i
  13.  
  14. Dim li1 As ListItem
  15. Set li1 = LV1.ListItems.Add()
  16. li1.Text = "Item 1"
  17. li1.Icon = 4
  18. li1.SmallIcon = 1
  19. LV1.ListItems(1).ListSubItems.Add , , "Field2"
  20. LV1.ListItems(1).ListSubItems.Add , , "Field3"
  21. LV1.ListItems(1).ListSubItems.Add , , "Field4"
  22.  
  23. Dim li2 As ListItem
  24. Set li2 = LV1.ListItems.Add()
  25. li2.Text = "Item 2"
  26. li2.Icon = 4
  27. li2.SmallIcon = 1
  28. LV1.ListItems(2).ListSubItems.Add , , "Field2"
  29. LV1.ListItems(2).ListSubItems.Add , , "Field3"
  30. LV1.ListItems(2).ListSubItems.Add , , "Field4"
  31.  
  32. Dim li3 As ListItem
  33. Set li3 = LV1.ListItems.Add()
  34. li3.Text = "Item 3"
  35. li3.Icon = 4
  36. li3.SmallIcon = 1
  37. LV1.ListItems(3).ListSubItems.Add , , "Field2"
  38. LV1.ListItems(3).ListSubItems.Add , , "Field3"
  39. LV1.ListItems(3).ListSubItems.Add , , "Field4"
  40.  
  41. With Combo1
  42. .AddItem "Icon View"
  43. .AddItem "Small Icon View"
  44. .AddItem "List View"
  45. .AddItem "Report View"
  46. End With
  47.  
  48. End Sub
  49.  
  50.  
Oct 18 '07 #1
0 17604

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Angelina | last post by:
Hi, I wanted to add a few items to my listview control. The values of these will be obtained from other controls on my interface. When the user clicks the select button, they will need to be...
9
by: Eva | last post by:
Hi, I wanted to know how i can enter values into a specific column of a listview. I have tried the following code but this seems to enter all my values into the first column!!! Can anyone...
2
by: cybertof | last post by:
Hello, Is there a solution to the following problem : When filling a listview (30 columns) with around 5000 items, it can take easily 10 sec for the listview to be filled. I have used...
6
by: Maheshkumar.R | last post by:
How i can store images in array @ runtime..? What are the possbile ways.. Thankz.. - Mähésh Kumär. R
3
by: Holmes | last post by:
Hello Ran into a bit of a problem here and have now exhausted my resources to getting this working What I am trying to do is load and show a simple vb form with a listbox in it Dim...
20
by: Ash Phillips | last post by:
Hi Everyone, I have this program I wrote in VB6 for family use. It's a DVD Database just for me to keep track of them cause I have so many lol. In VB6, I could add items to the ListView in...
2
by: dotnetnewbie | last post by:
Whilst looping through items in a listview I wish to have the option of inserting a new row (in the middle not necessarily at the end of the listview). thus if lvw is the listview name dim...
0
by: Steve K. | last post by:
I understand the concepts and rules for invoking UI methods from a non-UI thread. In the past I have always checked with the control's InvokeRequired property and Invoked my delegate accordingly. ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.