ListView.GridLines Property


Gets or sets a value indicating whether grid lines appear between the rows and columns containing the items and subitems in the control.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

member GridLines : bool with get, set

Property Value

Type: System.Boolean

true if grid lines are drawn around items and subitems; otherwise, false. The default is false.

The GridLines property has no effect unless the View property of the ListView control is set to Details. The GridLines property allows you to display lines to identify the rows and columns that are displayed in the ListView control when it displays items and their subitems. The grid lines that are displayed do not provide the ability to resize rows and columns as an application such as Microsoft Excel does. Only columns can be resized, if column headers are displayed, by moving the mouse pointer to the right side of the column to resize and then clicking and dragging until the column is the size you want. The grid lines feature is used to provide the user of the control with visible boundaries around items and subitems.

The following code example creates a ListView control with three ListViewItem objects specified and three ListViewItem.ListViewSubItem objects specified for each item. The example also creates ColumnHeader objects to display the subitems in details view. Two ImageList objects are also created in the code example to provide images for the ListViewItem objects. These ImageList objects are added to the LargeImageList and SmallImageList properties. The example uses the following properties in creating the ListView control.

This example requires that you have added the code to a Form and call the method created in the example from the constructor or another method on the form. The example also requires that images named MySmallImage1, MySmallImage2, MyLargeImage1, and MyLargeImage2 are located in the root directory of drive C.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top