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
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);
' 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)
See also
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
.NET Desktop feedback