473,408 Members | 1,809 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,408 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 17672

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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.