471,319 Members | 1,649 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

Cannot add bitmap to ListView other than in first column

GT
Could someone please explain how to add images to a ListView other than in
the first column?
Feb 9 '06 #1
2 4102
Hi GT,
not sure I am quite following you when you say "first column", since a
ListView is a one dimensional structure. What are you trying to do? If you
want a 2D structure you probably want to have a list of listviews which you
can access.

Mark Dawson
http://www.markdawson.org

"GT" wrote:
Could someone please explain how to add images to a ListView other than in
the first column?

Feb 9 '06 #2
GT
Ok, consider the example code given under the ListView class in the MSDN
library
(http://msdn.microsoft.com/library/de...lasstopic.asp).
The code generates a ListView with 4 colums and 3 rows (in additon to the
column heading) . At the end of the code example a bitmap image is added to
the cell elements in the first colums by using the .Images.Add() method (ref
cited code at the bottom of my reply).
My question is: How can the bitmap images be added to the ListView elements
other than in the first column, that is, where the example code displays the
integers 2,3,5,6,8 and 9?

==================================
' Create two ImageList objects.
Dim imageListSmall As New ImageList()
Dim imageListLarge As New ImageList()

' Initialize the ImageList objects with bitmaps.
imageListSmall.Images.Add(Bitmap.FromFile("C:\MySm allImage1.bmp"))
imageListSmall.Images.Add(Bitmap.FromFile("C:\MySm allImage2.bmp"))
imageListLarge.Images.Add(Bitmap.FromFile("C:\MyLa rgeImage1.bmp"))
imageListLarge.Images.Add(Bitmap.FromFile("C:\MyLa rgeImage2.bmp"))

'Assign the ImageList objects to the ListView.
listView1.LargeImageList = imageListLarge
listView1.SmallImageList = imageListSmall

' Add the ListView to the control collection.
Me.Controls.Add(listView1)
End Sub 'CreateMyListView
======================================

"Mark R. Dawson" wrote:
Hi GT,
not sure I am quite following you when you say "first column", since a
ListView is a one dimensional structure. What are you trying to do? If you
want a 2D structure you probably want to have a list of listviews which you
can access.

Mark Dawson
http://www.markdawson.org

"GT" wrote:
Could someone please explain how to add images to a ListView other than in
the first column?

Feb 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Ivan Figueredo | last post: by
reply views Thread by Andrew | last post: by
3 posts views Thread by Rob Richardson | last post: by
7 posts views Thread by BobAchgill | last post: by
12 posts views Thread by J L | last post: by
6 posts views Thread by Dave | last post: by
10 posts views Thread by Rob | last post: by
reply views Thread by rosydwin | last post: by

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.