Provides data for the ListView::DrawSubItem event.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The ListView::DrawSubItem event is raised by a ListView control when its ListView::OwnerDraw property is set to true and its View property is set to Details. The passed to the event handler contains information about the ListViewItem::ListViewSubItem to draw and also provides methods to help you draw the subitem.
Use the ItemState or Item properties to retrieve information about the parent item of the subitem to draw. To retrieve the ListViewItem::ListViewSubItem itself, use the SubItem property. Use the Header property to retrieve the ColumnHeader representing the header of the column in which the subitem is displayed.
Use the Graphics property to do the actual drawing within the area specified by the Bounds property. To draw standard ListView elements that do not need customization, use the DrawBackground, DrawText, and DrawFocusRectangle methods.
Use the DrawDefault property when you want the operating system to draw the subitem. This is useful when you want to customize only specific subitems.
The following code example demonstrates how to provide custom drawing for a ListView control. The ListView control in the example has a gradient background. Subitems with negative values have a red foreground and a black background.
A handler for the ListView::DrawItem event draws the background for entire items. A handler for the ListView::DrawSubItem event draws the text values and both the text and background for subitems that have negative values. A handler for the DrawColumnHeader event draws each column header.
A ContextMenu component provides a way to switch between the details view and the list view. In the list view, only the ListView::DrawItem event is fired. In this case, the text and background are both drawn in the ListView::DrawItem event handler.
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.