Image Columns in ListView

  • Thread starter Thread starter Marc W.
  • Start date Start date
M

Marc W.

Hello,

I am trying to create a ListView object on my form with two columns. A
small, 32 pixel wide column on the left for holding images, and a column
that takes up the rest of the ListView on the right for storing text.

My question is this: how do I store images in this first column? I see all
kinds of support for small icon images and large icon images, but those are
for views that I do not want. Is there any way to do this?

Thanks,
Marc W.
 
Hello Marc,

ListView supports so called "status images". These are small icons displayed
to the left of the item (that is, the leftmost column in the view) and work
in the Report mode you probably want your view to display itself in. They,
however, AFAIK are not supported at the Framework level and you might need
to do some amount of P/Invoke to the appropriate Windows APIs to enable this
feature. I believe I have seen an article on some website (was it
CodeProject?) that demonstrated how to do that.
 
Hello,

I am trying to create a ListView object on my form with two columns. A
small, 32 pixel wide column on the left for holding images, and a column
that takes up the rest of the ListView on the right for storing text.

My question is this: how do I store images in this first column? I see all
kinds of support for small icon images and large icon images, but those are
for views that I do not want. Is there any way to do this?

Thanks,
Marc W.

Marc

Can you 'cheat' and add a ListView item with no text, just an icon,
and then a sub-item with your text? Something like:

lvItem = new ListViewItem("", intIconIndex);
lvItem.SubItems.Add("Your text");
lvMain.Items.Add(lvItem);

All you would need to do then is set up an ImageList and associate the
ListView with it.
 
Hi Marc
Do u have the soln?? pls mail me to (e-mail address removed)
-----Original Message-----
Hello Marc,

ListView supports so called "status images". These are small icons displayed
to the left of the item (that is, the leftmost column in the view) and work
in the Report mode you probably want your view to display itself in. They,
however, AFAIK are not supported at the Framework level and you might need
to do some amount of P/Invoke to the appropriate Windows APIs to enable this
feature. I believe I have seen an article on some website (was it
CodeProject?) that demonstrated how to do that.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Marc W. said:
Hello,

I am trying to create a ListView object on my form with two columns. A
small, 32 pixel wide column on the left for holding images, and a column
that takes up the rest of the ListView on the right for storing text.

My question is this: how do I store images in this first column? I see all
kinds of support for small icon images and large icon
images, but those
are
for views that I do not want. Is there any way to do this?

Thanks,
Marc W.

.
 
Back
Top