473,395 Members | 2,423 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,395 software developers and data experts.

very stupid listview icon problem!

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

Jul 23 '07 #1
2 4769

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/lib...DownFilterText
Adrian.
--
[Please mark my answer if it was helpful to you]


"giddy" wrote:
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

Jul 23 '07 #2

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.
--
[Please mark my answer if it was helpful to you]


"giddy" wrote:
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

Jul 23 '07 #3

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

Similar topics

10
by: Zeljko | last post by:
Hi, I have a form with a tray icon. However, when I minimize the form, it stays visible - not in the task bar (I have showintaskbar property set to false), but in a form of a rectangle sitting...
1
by: Jim McLeod | last post by:
Dear Group How am I going wrong with this drag and drop procedure.. private void ResourceList_ItemDrag(object sender, System.Windows.Forms.ItemDragEventArgs e System.Windows.Forms.ListView...
2
by: Brian | last post by:
Dear my friends, I have been helped by many C# gurus here, thank you very much. My small application can help you fetch some good pictures from Internet. You can get it from...
3
by: scoobydoo | last post by:
hi, I have a problem displaying icons at the right colour depthin a ListView. I've made an icon file, (using IconWorkshop 5), it has 3 icons within it. A 32x32 32bpp XP style icon, a 32x32...
0
by: scoobydoo | last post by:
Can anybody tell me how to define which icon is displayed in a listView? I'm writing in c#. My implementation ALWAYS uses the windows XP version of the icon within the ..ico file. I would like...
2
by: farmer | last post by:
I need to populate a listbox of other listview with selected listview items.although the following code works perfecty I want to use an Array (for various reasons) for Each ListItem In...
3
by: Nina | last post by:
Hi there, I assigned icon for a window's form using form's Icon property at design time. Now I want to change the icon. I tried to replace the old icon with the new icon using form's Icon...
0
by: pagates | last post by:
Hello All, I am not sure if this is something Im overlooking, or a bug, or if its "just the way it is." I am using VS2003. I have a listview (in Details view), with the SmallImageList...
3
by: Gardner Andersen | last post by:
I have an imagelist with 7 icons images in the collection. I am trying to assign the icons to the items in a listview. In the designer, the proper icons appear next to the listview items (a fixed...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.