This documentation is archived and is not being maintained.

ListViewItem.ListViewSubItemCollection.AddRange Method (String[], Color, Color, Font)

Creates new subitems based on an array and adds them to the collection with specified foreground color, background color, and font.

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

public void AddRange(
	string[] items,
	Color foreColor,
	Color backColor,
	Font font
)

Parameters

items
Type: System.String[]
An array of strings representing the text of each subitem to add to the collection.
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.

You can use this version of the AddRange method to add an array of strings to the collection, where each string in the collection represents the text of a new subitem. In addition, this version of the AddRange method allows you to specify the foreground color, background color, and font for each subitem. You can use the other version of the AddRange method that accepts an array of strings as a parameter if you do not want to specify foreground color, background color, and font settings for each subitem. If you want to reuse existing ListViewItem.ListViewSubItem objects and add them to the collection, you can use the version of the AddRange method that accepts an array of ListViewItem.ListViewSubItem objects as a parameter.

If you want to add a single ListViewItem.ListViewSubItem, use the Add method. You can also use the Insert method if you want to add a single ListViewItem.ListViewSubItem 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, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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