System.Windows.Forms.ListViewItem Class

Represents an item in a System.Windows.Forms.ListView control.

See Also: ListViewItem Members

Syntax

[System.ComponentModel.TypeConverter(typeof(System.Windows.Forms.ListViewItemConverter))]
[System.ComponentModel.ToolboxItem(false)]
[System.ComponentModel.DesignTimeVisible(false)]
[System.ComponentModel.DefaultProperty("Text")]
public class ListViewItem : ICloneable, System.Runtime.Serialization.ISerializable

Remarks

The System.Windows.Forms.ListView control is similar to a System.Windows.Forms.ListBox in that it displays a list of items. The main difference is that the System.Windows.Forms.ListView control provides a number of different ways items can be viewed by the user. The System.Windows.Forms.ListViewItem class defines the appearance, behavior, and data associated with an item that is displayed in the System.Windows.Forms.ListView control. System.Windows.Forms.ListViewItem objects can be displayed in the System.Windows.Forms.ListView control in one of four different views. Items can be displayed as large or small icons or as small icons in a vertical list. Items can also have subitems that contain information that is related to the parent item. The fourth view style, details view, allows you to display the item and its subitems in a grid with column headers that can be used to identify the information being displayed in a subitem.

Most of the properties of the System.Windows.Forms.ListViewItem class provide ways to change the display of the item in the System.Windows.Forms.ListView control it is associated with. The ListViewItem.BackColor, ListViewItem.ForeColor, and ListViewItem.Font properties allow you to change how the text of the item is displayed in the System.Windows.Forms.ListView control. The ListViewItem.ImageIndex property allows you to specify the image to load from the System.Windows.Forms.ImageList that is assigned to the System.Windows.Forms.ListView control (by setting the ListView.LargeImageList or ListView.SmallImageList properties of the System.Windows.Forms.ListView). Items can display check boxes in order to obtain item choices from the user in a way similar to a System.Windows.Forms.CheckedListBox control. You can use the ListViewItem.Checked property to determine if an item is checked, or to select or clear the check box at run time. Items can display any number of subitems when the ListView.View property of the associated System.Windows.Forms.ListView control is set to View.Details and columns are defined in the System.Windows.Forms.ListView.ColumnHeaderCollection of the System.Windows.Forms.ListView control. You can add subitems to an item by calling the System.Windows.Forms.ListViewItem.ListViewSubItemCollection.Add(System.Windows.Forms.ListViewItem.ListViewSubItem) method of the System.Windows.Forms.ListViewItem.ListViewSubItemCollection class. The ListViewItem.SubItems property allows you to gain access to the System.Windows.Forms.ListViewItem.ListViewSubItemCollection class and its members.

Some of the properties and methods of the System.Windows.Forms.ListViewItem class are item-specific versions of properties and methods in the System.Windows.Forms.ListView control. For example, the ListViewItem.EnsureVisible method is similar to the System.Windows.Forms.ListView version of the method, but the System.Windows.Forms.ListViewItem version affects only the current item.

The System.Windows.Forms.ListViewItem class also provides methods that are not versions of System.Windows.Forms.ListView methods. The ListViewItem.BeginEdit method places the item's text into edit mode so the user can change the item's text (when the ListView.LabelEdit property of the System.Windows.Forms.ListView control is set to true). The ListViewItem.Clone method allows you to create copies of existing System.Windows.Forms.ListViewItem objects to reuse in other System.Windows.Forms.ListView controls.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0