Export (0) Print
Expand All

ListViewItem.ListViewSubItemCollection.Add Method (String, Color, Color, Font)

Adds a subitem to the collection with specified text, foreground color, background color, and font settings.

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

public ListViewItem.ListViewSubItem Add(
	string text,
	Color foreColor,
	Color backColor,
	Font font
)

Parameters

text
Type: System.String

The text to display for the subitem.

foreColor
Type: System.Drawing.Color

A Color that represents the foreground color of the subitem.

backColor
Type: System.Drawing.Color

A Color that represents the background color of the subitem.

font
Type: System.Drawing.Font

A Font that represents the typeface to display the subitem's text in.

Return Value

Type: System.Windows.Forms.ListViewItem.ListViewSubItem
The ListViewItem.ListViewSubItem that was added to the collection.

This version of the Add method allows you to add a subitem to the collection by specifying the text of the subitem. In addition, this version of the Add method allows you to specify the initial foreground color, background color, and font of the subitem text. When this method is called, a new ListViewItem.ListViewSubItem is created with the specified text. You can then use the ListViewItem.ListViewSubItem that is returned by this method to set properties and call methods to manipulate the subitem. If you already have an existing ListViewItem.ListViewSubItem that you want to add to the collection, you can use the version of the Add method that accepts a ListViewItem.ListViewSubItem as a parameter, or use the Insert method if you want to add the subitem at a specific position in the collection.

NoteNote

By default, subitems use the foreground color, background color, and font specified for the parent item. Set the ListViewItem.UseItemStyleForSubItems property to false to prevent the parent item styles from overriding the subitem styles.

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft