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.

System_CAPS_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
Available since 1.1
Return to top
Show: