hi,
I have a listview on a form, the View is set to Tile. I also have an
image list tied to the *smallImageList property, i have one image in
the image list, its a png : 32X32
When i do this, i dont see an icon and the SubItem text!
lstvUsers.Columns.Add(Privilege");//added only so the tile detail is
visible
foreach (User _user in _users.Users)
{
ListViewItem lstviUser = new
ListViewItem(_user.Username,"User.png");
lstviUser.SubItems.Add(_user.Privilege.ToString());
lstvUsers.Items.Add(lstviUser);
}
When i added my imagelist to the largeImageList property the icon
shows up. BUT I still dont see the subitem text!? What am i doing
wrong!!!!
Gideon
Adrian Voicu - 23 Jul 2007 16:38 GMT
If you are using a small image list to hold your icons you should set the
view property to SmallIcon. Similary if you want to use a large image list,
set the view property to LargeIcon. When you add items to your list view,
specify the index of the image from the image list to use for that item:
listView1.Columns.Add("Privilege");
System.Drawing.Icon myIcon = new System.Drawing.Icon("Icon1.ico");
ImageList myImageList = new ImageList();
myImageList.Images.Add(myIcon);
listView1.SmallImageList = myImageList;
for (int i = 0; i < 5; i++)
{
listView1.Items.Add(i.ToString(), 0);
}
http://msdn2.microsoft.com/en-us/library/system.windows.forms.listview.smallimag
elist(VS.71).aspx#Mtps_DropDownFilterText
Adrian.

Signature
[Please mark my answer if it was helpful to you]
> hi,
>
[quoted text clipped - 19 lines]
>
> Gideon
Adrian Voicu - 23 Jul 2007 16:48 GMT
I forgot to mention that you should create columns for each sub item that
you are adding to a list view item. If you set the view property of the list
view to Details you should be able to see all the data that you have added to
the list view.
listView1.Columns.Add("Privilege");
listView1.Columns.Add("Details");
System.Drawing.Icon myIcon = new System.Drawing.Icon("Icon1.ico");
ImageList myImageList = new ImageList();
myImageList.Images.Add(myIcon);
listView1.SmallImageList = myImageList;
for (int i = 0; i < 5; i++)
{
ListViewItem lstviUser = new ListViewItem(i.ToString(),0);
lstviUser.SubItems.Add(i.ToString() + " S");
listView1.Items.Add(lstviUser);
}
Adrian.

Signature
[Please mark my answer if it was helpful to you]
> hi,
>
[quoted text clipped - 19 lines]
>
> Gideon