Thursday, November 22, 2012

C# Windows Forms ListView with multiple columns

A ListBox control in a C# windows forms, can display only one column of data, but there are instances when we want to display multiple columns of data. One option is to use the DataGrid control, but we can also use the ListView control to display multiple column data.

The
ListView can be used to display static information, which the user will not be changing, in this post we shall see on how to use the ListView control to display multiple columns of data in a C# Windows Form.

 1. Create a new / open an existing C# Windows application
2. Open and existing / Add a new Windows Form to the Project
3. Drag
a ListView control into the form.
4. Open the Properties window of the ListView.
5. Open the Columns (Collection) Property of the
ListView and add the Columns Required.
6. Now Open the Items (Collection) Property, use the Add Button to add the values for the 1st column in the list.


7. Now under each Item, we can add Multiple Sub Items by using the Sub Items property, all the Sub Items added under each item will be listed in the same row as the item in successive columns.




8. The Final ListView looks as follows.






Search Flipkart Products:
Flipkart.com

1 comment:

Anonymous said...

The ListView Controls for Windows Forms is capable of adding multi-column to listview in C# at design time.