DrawListViewSubItemEventArgs Class
TOC
Collapse the table of content
Expand the table of content

DrawListViewSubItemEventArgs Class

 

Provides data for the ListView.DrawSubItem event.

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

System.Object
  System.EventArgs
    System.Windows.Forms.DrawListViewSubItemEventArgs

type DrawListViewSubItemEventArgs = 
    class
        inherit EventArgs
    end

NameDescription
System_CAPS_pubpropertyBounds

Gets the size and location of the ListViewItem.ListViewSubItem to draw.

System_CAPS_pubpropertyColumnIndex

Gets the index of the ListView column in which the ListViewItem.ListViewSubItem is displayed.

System_CAPS_pubpropertyDrawDefault

Gets or sets a value indicating whether the ListViewItem.ListViewSubItem should be drawn by the operating system instead of owner-drawn.

System_CAPS_pubpropertyGraphics

Gets the Graphics used to draw the ListViewItem.ListViewSubItem.

System_CAPS_pubpropertyHeader

Gets the header of the ListView column in which the ListViewItem.ListViewSubItem is displayed.

System_CAPS_pubpropertyItem

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

System_CAPS_pubpropertyItemIndex

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

System_CAPS_pubpropertyItemState

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

System_CAPS_pubpropertySubItem

NameDescription
System_CAPS_pubmethodDrawBackground()

Draws the background of the ListViewItem.ListViewSubItem using its current background color.

System_CAPS_pubmethodDrawFocusRectangle(Rectangle)

Draws a focus rectangle for the ListViewItem.ListViewSubItem if the parent ListViewItem has focus.

System_CAPS_pubmethodDrawText()

Draws the text of the ListViewItem.ListViewSubItem using its current foreground color.

System_CAPS_pubmethodDrawText(TextFormatFlags)

Draws the text of the ListViewItem.ListViewSubItem using its current foreground color and formatting it with the specified TextFormatFlags values.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

The ListView.DrawSubItem event enables you to customize (or owner-draw) the appearance of a ListView control in the details view.

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 DrawListViewSubItemEventArgs 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.

System_CAPS_noteNote

To avoid issues with graphics flickering when owner drawing, override the ListView control and set the DoubleBuffered property to true. This feature is available only on Windows XP and the Windows Server 2003 family when your application calls the Application.EnableVisualStyles method.

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.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft