www.softwareriviera.com
Software Code
    New Code     Most Interesting     Don't Miss     Our picks  
C# - section

View Article
Add a new entry into a ListView control
See how you can add a new entry into a ListView control. The code below uses a custom object of type AppDraggedFolder which has two properties: FolderPath and FolderDescription.
public ListViewItem AddDraggedFolderItemToListView(ListView listView, AppDraggedFolder draggedFolder)
{
ListViewItem lvItem = new ListViewItem();
lvItem.Tag = draggedFolder;
lvItem.SubItems.Add(new ListViewItem.ListViewSubItem());
lvItem.SubItems.Add(new ListViewItem.ListViewSubItem());
lvItem.SubItems.Add(new ListViewItem.ListViewSubItem());

//Set image index if necessary
//lvItem.ImageIndex = 4;

//Set values
lvItem.SubItems[1].Text = draggedFolder.FolderPath;
lvItem.SubItems[2].Text = draggedFolder.FolderDescription;

listView.Items.Add(lvItem);

return lvItem;
}

Date: 2012-5-30    Written by: Admin A
     See all articles in this section
Copyright © 2007-2009 SoftwareRiviera.com. All rights reserved.  | Terms of use | Disclaimer | Privacy Policy |