This documentation is archived and is not being maintained.

DrawListViewSubItemEventArgs.Item Property

Gets the parent ListViewItem of the ListViewItem.ListViewSubItem to draw.

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

public ListViewItem Item { get; }

Property Value

Type: System.Windows.Forms.ListViewItem
A ListViewItem that represents the parent of the ListViewItem.ListViewSubItem to draw.

Use this property to access the ListViewItem parent of the ListViewItem.ListViewSubItem to draw. This is useful when the ItemState property does not provide adequate information to meet your needs. The ItemState property provides only basic state information that you can use, for example, to determine whether the parent item is selected, checked, or focused. The Item property, on the other hand, allows you to access all members of the parent ListViewItem.

To access the ListViewItem.ListViewSubItem being drawn, use the SubItem property.

The following code example demonstrates the use of this member. In the example, an event handler reports on the occurrence of the ListView.DrawSubItem event. This report helps you to learn when the event occurs and can assist you in debugging.

To run the example code, paste it into a project that contains an instance of type ListView named ListView1. Then ensure that the event handler is associated with the ListView.DrawSubItem event.

private void ListView1_DrawSubItem(Object sender, DrawListViewSubItemEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "DrawDefault", e.DrawDefault );
messageBoxCS.AppendFormat("{0} = {1}", "Graphics", e.Graphics );
messageBoxCS.AppendFormat("{0} = {1}", "Bounds", e.Bounds );
messageBoxCS.AppendFormat("{0} = {1}", "Item", e.Item );
messageBoxCS.AppendFormat("{0} = {1}", "SubItem", e.SubItem );
messageBoxCS.AppendFormat("{0} = {1}", "ItemIndex", e.ItemIndex );
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendFormat("{0} = {1}", "Header", e.Header );
messageBoxCS.AppendFormat("{0} = {1}", "ItemState", e.ItemState );
MessageBox.Show(messageBoxCS.ToString(), "DrawSubItem Event" );

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

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

.NET Framework

Supported in: 3.5, 3.0, 2.0