Export (0) Print
Expand All

How to: Add Columns to the Windows Forms ListView Control

In the Details view, the ListView control can display multiple columns for each list item. You can use the columns to display to the user several types of information about each list item. For example, a list of files could display the file name, file type, size, and date the file was last modified. For information about populating the columns after they are created, see How to: Display Subitems in Columns with the Windows Forms ListView Control.

To add columns programmatically

  1. Set the control's View property to Details.

  2. Use the Add method of the list view's Columns property.

    
            // Set to details view.
            listView1.View = View.Details;
            // Add a column with width 20 and left alignment.
            listView1.Columns.Add("File type", 20, HorizontalAlignment.Left);
    
    
    
    

Community Additions

ADD
Show:
© 2014 Microsoft