Results 1 to 3 of 3

Thread: [RESOLVED] Adding items to a detailed ListView

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Resolved [RESOLVED] Adding items to a detailed ListView

    I have a ListView that is in detailed view and it has 3 columns (col1, col2, and col3).

    How do I add an item to each column?
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  2. #2
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Re: Adding items to a detailed ListView

    You still just add a ListViewItem, but the ListViewItem has SubItems. In this code I create an item with an image index of 0 and then add a sub item to it. The sub item shows up in the second column.
    Code:
           private void DisplayLoadedAssemblies()
            {
                Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                foreach (Assembly a in assemblies)
                {
                    AssemblyName an = a.GetName();
                    ListViewItem item = new ListViewItem(an.Name.ToString(), 0);
                    item.SubItems.Add(an.Version.ToString());
                    this.lvAssemblies.Items.Add(item);
    
                    Debug.WriteLine(a.ToString());
                }
            }
    Mike

  3. #3

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Adding items to a detailed ListView

    Thanks. I knew I had to do something with the SubItem.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width