Add Data to a ListView : ListView « GUI Windows Form « C# / C Sharp






Add Data to a ListView


using System;
using System.Windows.Forms;
using System.IO;

public class TagPropertyExample : System.Windows.Forms.Form {
    ListView listView = new ListView();
    
    public TagPropertyExample () {
        listView.Left = 10;
        listView.Top = 10;
        
        listView.Size = new System.Drawing.Size(292, 273);
        DirectoryInfo directory = new DirectoryInfo("C:\\");
        FileInfo[] files = directory.GetFiles();

        foreach (FileInfo file in files) {
            ListViewItem item = listView.Items.Add(file.Name);
            item.ImageIndex = 0;
            item.Tag = file;
        }
        this.Controls.Add(listView);
    }


    public static void Main(){
       Application.Run(new TagPropertyExample());
    }
}
           
       








Related examples in the same category

1.Windows Explorer-Like Program: extends ListView
2.Dragging and dropping between ListView
3.ListView Item clicked eventListView Item clicked event
4.Folder Browser based on ListViewFolder Browser based on ListView
5.Set ColumnHeader for ListView
6.Sort a List View by Any ColumnSort a List View by Any Column
7.Extends ListViewItem
8.Use RadioButton to control the ListView display styleUse RadioButton to control the ListView display style
9.Display Directory info in a ListViewDisplay Directory info in a ListView
10.Add ListView column and insert ListView rowsAdd ListView column and insert ListView rows
11.Use ListViewItem to display file information
12.ListView ExampleListView Example
13.ListView Country: image and fontListView Country: image and font
14.Use ListView to display File info: name, size and dateUse ListView to display File info: name, size and date
15.Use ListView to display file name and double click the name to execute that fileUse ListView to display file name and double click the name to execute that file
16.Use ListView to diaplay folder info and double click to enter that directoryUse ListView to diaplay folder info and double click to enter that directory