DrawListViewItemEventArgs::DrawText Method ()

 

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

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

public:
void DrawText()

Use this method to draw the item text using the current values of the ListViewItem::ForeColor and ListViewItem::Font properties. The text is drawn within the area specified by the Bounds property. You can also draw the text manually using the Graphics retrieved through the Graphics property.

The DrawText method is most useful when the ListView::View property is set to a value other than View::Details. In the details view, this method draws the text for the ListViewItem, but does not draw the text for subitems. Therefore, in the details view, it is generally more convenient to draw all of the ListView text in a handler for the ListView::DrawSubItem event.

The following code example demonstrates how to use the DrawText method in an application that provides custom drawing for a ListView control. In the example, a handler for the ListView::DrawItem event draws the background for entire items. In all views except the details view, this handler also draws the foreground text. In the details view, the foreground text is drawn in the ListView::DrawSubItem event.

For the complete example, see the DrawListViewItemEventArgs overview reference topic.

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

.NET Framework
Available since 2.0
Return to top
Show: