473,385 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

how to fill listview without image

I'm trying to fill a listview with data. I'm using the example from the help
file, but how do I modify this to avoid using images? I want the exact same
layout but without images. This procedure seems so dependent on the image
being the "anchor" of each row that I don't understand how to modify it.

Thanks.
Dim lv As ListView
lv = Me.ListView1
With lv
.View = View.Details
.LabelEdit = True
.AllowColumnReorder = True
.CheckBoxes = False
.FullRowSelect = True
.GridLines = True
.Sorting = SortOrder.Ascending
End With
Dim item1 As New ListViewItem("item1", 0)
With item1
.Checked = True
.SubItems.Add("1")
.SubItems.Add("2")
.SubItems.Add("3")
End With
Dim item2 As New ListViewItem("item2", 1)
With item2
.Checked = True
.SubItems.Add("4")
.SubItems.Add("5")
.SubItems.Add("6")
End With
Dim item3 As New ListViewItem("item3", 0)
With item3
.Checked = True
.SubItems.Add("7")
.SubItems.Add("8")
.SubItems.Add("9")
End With
Dim item4 As New ListViewItem("item4", 0)
With item4
.Checked = True
.SubItems.Add("7")
.SubItems.Add("8")
.SubItems.Add("9")
End With
With lv
.Columns.Add("Column 1", -2, HorizontalAlignment.Left)
.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
.Columns.Add("Column 4", -2, HorizontalAlignment.Left)
.Items.AddRange(New ListViewItem() {item1, item2, item3, item4})
End With

Dim imageListSmall As New ImageList
Dim imageListLarge As New ImageList

' Initialize the ImageList objects with bitmaps.

imageListSmall.Images.Add(Bitmap.FromFile("D:\Data \MySmallImage1.bmp"))

imageListSmall.Images.Add(Bitmap.FromFile("D:\Data \MySmallImage2.bmp"))

imageListLarge.Images.Add(Bitmap.FromFile("D:\Data \MyLargeImage1.bmp"))

imageListLarge.Images.Add(Bitmap.FromFile("D:\Data \MyLargeImage2.bmp"))

''Assign the ImageList objects to the ListView.
lv.LargeImageList = imageListLarge
lv.SmallImageList = imageListSmall
Me.Controls.Add(lv)
Apr 27 '06 #1
2 2614
mrmagoo,

The problem is the code that creates the columns, lines like this:

..Columns.Add("Column 1", -2, HorizontalAlignment.Left)

You need to change the negative number to a positive number representing a
column width.

You can just leave all the image stuff out, that's not the problem.

Kerry Moorman
"mrmagoo" wrote:
I'm trying to fill a listview with data. I'm using the example from the help
file, but how do I modify this to avoid using images? I want the exact same
layout but without images. This procedure seems so dependent on the image
being the "anchor" of each row that I don't understand how to modify it.

Thanks.
Dim lv As ListView
lv = Me.ListView1
With lv
.View = View.Details
.LabelEdit = True
.AllowColumnReorder = True
.CheckBoxes = False
.FullRowSelect = True
.GridLines = True
.Sorting = SortOrder.Ascending
End With
Dim item1 As New ListViewItem("item1", 0)
With item1
.Checked = True
.SubItems.Add("1")
.SubItems.Add("2")
.SubItems.Add("3")
End With
Dim item2 As New ListViewItem("item2", 1)
With item2
.Checked = True
.SubItems.Add("4")
.SubItems.Add("5")
.SubItems.Add("6")
End With
Dim item3 As New ListViewItem("item3", 0)
With item3
.Checked = True
.SubItems.Add("7")
.SubItems.Add("8")
.SubItems.Add("9")
End With
Dim item4 As New ListViewItem("item4", 0)
With item4
.Checked = True
.SubItems.Add("7")
.SubItems.Add("8")
.SubItems.Add("9")
End With
With lv
.Columns.Add("Column 1", -2, HorizontalAlignment.Left)
.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
.Columns.Add("Column 4", -2, HorizontalAlignment.Left)
.Items.AddRange(New ListViewItem() {item1, item2, item3, item4})
End With

Dim imageListSmall As New ImageList
Dim imageListLarge As New ImageList

' Initialize the ImageList objects with bitmaps.

imageListSmall.Images.Add(Bitmap.FromFile("D:\Data \MySmallImage1.bmp"))

imageListSmall.Images.Add(Bitmap.FromFile("D:\Data \MySmallImage2.bmp"))

imageListLarge.Images.Add(Bitmap.FromFile("D:\Data \MyLargeImage1.bmp"))

imageListLarge.Images.Add(Bitmap.FromFile("D:\Data \MyLargeImage2.bmp"))

''Assign the ImageList objects to the ListView.
lv.LargeImageList = imageListLarge
lv.SmallImageList = imageListSmall
Me.Controls.Add(lv)

Apr 27 '06 #2
Beautiful. Thanks.
"Kerry Moorman" <Ke**********@discussions.microsoft.com> wrote in message
news:FE**********************************@microsof t.com...
mrmagoo,

The problem is the code that creates the columns, lines like this:

.Columns.Add("Column 1", -2, HorizontalAlignment.Left)

You need to change the negative number to a positive number representing a
column width.

You can just leave all the image stuff out, that's not the problem.

Kerry Moorman
"mrmagoo" wrote:
I'm trying to fill a listview with data. I'm using the example from the help file, but how do I modify this to avoid using images? I want the exact same layout but without images. This procedure seems so dependent on the image being the "anchor" of each row that I don't understand how to modify it.

Thanks.
Dim lv As ListView
lv = Me.ListView1
With lv
.View = View.Details
.LabelEdit = True
.AllowColumnReorder = True
.CheckBoxes = False
.FullRowSelect = True
.GridLines = True
.Sorting = SortOrder.Ascending
End With
Dim item1 As New ListViewItem("item1", 0)
With item1
.Checked = True
.SubItems.Add("1")
.SubItems.Add("2")
.SubItems.Add("3")
End With
Dim item2 As New ListViewItem("item2", 1)
With item2
.Checked = True
.SubItems.Add("4")
.SubItems.Add("5")
.SubItems.Add("6")
End With
Dim item3 As New ListViewItem("item3", 0)
With item3
.Checked = True
.SubItems.Add("7")
.SubItems.Add("8")
.SubItems.Add("9")
End With
Dim item4 As New ListViewItem("item4", 0)
With item4
.Checked = True
.SubItems.Add("7")
.SubItems.Add("8")
.SubItems.Add("9")
End With
With lv
.Columns.Add("Column 1", -2, HorizontalAlignment.Left)
.Columns.Add("Column 2", -2, HorizontalAlignment.Left)
.Columns.Add("Column 3", -2, HorizontalAlignment.Left)
.Columns.Add("Column 4", -2, HorizontalAlignment.Left)
.Items.AddRange(New ListViewItem() {item1, item2, item3, item4}) End With

Dim imageListSmall As New ImageList
Dim imageListLarge As New ImageList

' Initialize the ImageList objects with bitmaps.

imageListSmall.Images.Add(Bitmap.FromFile("D:\Data \MySmallImage1.bmp"))

imageListSmall.Images.Add(Bitmap.FromFile("D:\Data \MySmallImage2.bmp"))

imageListLarge.Images.Add(Bitmap.FromFile("D:\Data \MyLargeImage1.bmp"))

imageListLarge.Images.Add(Bitmap.FromFile("D:\Data \MyLargeImage2.bmp"))

''Assign the ImageList objects to the ListView.
lv.LargeImageList = imageListLarge
lv.SmallImageList = imageListSmall
Me.Controls.Add(lv)

Apr 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Silvia | last post by:
Hi, I have a program that capture images and put this into a listview (using imagelist), the problem is when I delete de image the listview, when do that and capture another image, the image...
3
by: Vagabond Software | last post by:
I'm trying to display thumbnail images in a Listview that look more like the Windows thumbnail view. Everything is working pretty good, but my thumbnails are decidedly not like the Windows...
13
by: Maheshkumar.R | last post by:
hi groups, I have placed an listview control, i want to iterate thru the control and find the clicked event items. listView2.Items.Add(fname.ToString(), i); how i can perform the iteration...
0
by: Chris Putnam | last post by:
I am working on an application that includes a feature where a directory is spidered and thumbnails are displayed. I have it pretty much down, but when the bitmaps are loaded from file, memory is...
0
by: Silvia | last post by:
Hi, I have a program that capture images and put this into a listview (using imagelist), the problem is when I delete de image the listview, when do that and capture another image, the image...
11
by: Alan T | last post by:
Does the ListView supports sort? I want to have a up/down arrow/triangle that show it is sorted asc or desc on the column headers when I click the column header. May be I need a third-party...
0
by: Tristan | last post by:
I have a ListView control with one column. It is in the Details view mode. I populate its items dynamically. Some items will have associated images from the listview's imagelist and some will...
2
by: Adrien Reboisson | last post by:
I'm trying to build a basic DB explorer using C# & Visual Studio 2005. I installed SQL Server 2005 Express, created a blank project, dropped a TreeView, a ListView and a DataGridView : DB objects...
5
by: Todd Barlow | last post by:
Hi, When I try to set the BackgroundImage property on a ListView, the project fails to run. Sometimes a generic error message appears telling me that memory might be corrupt. Sometimes the error...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.