Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / July 2007

Tip: Looking for answers? Try searching our database.

very stupid listview icon problem!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
giddy - 23 Jul 2007 05:29 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.