DrawListViewColumnHeaderEventArgs Class
Provides data for the ListView::DrawColumnHeader event.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
The DrawListViewColumnHeaderEventArgs type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | DrawListViewColumnHeaderEventArgs | Initializes a new instance of the DrawListViewColumnHeaderEventArgs class. |
| Name | Description | |
|---|---|---|
![]() | BackColor | Gets the background color of the header. |
![]() | Bounds | Gets the size and location of the column header to draw. |
![]() | ColumnIndex | Gets the index of the ColumnHeader representing the header to draw. |
![]() | DrawDefault | Gets or sets a value indicating whether the column header should be drawn by the operating system instead of owner-drawn. |
![]() | Font | Gets the font used to draw the column header text. |
![]() | ForeColor | Gets the foreground color of the header. |
![]() | Graphics | Gets the Graphics used to draw the column header. |
![]() | Header | Gets the ColumnHeader representing the column header to draw. |
![]() | State | Gets the current state of the column header. |
| Name | Description | |
|---|---|---|
![]() | DrawBackground | Draws the background of the column header. |
![]() | DrawText() | Draws the column header text using the default formatting. |
![]() | DrawText(TextFormatFlags) | Draws the column header text, formatting it with the specified TextFormatFlags values. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
The ListView::DrawColumnHeader event lets you customize (or owner-draw) the appearance of a ListView control in the details view.
The ListView::DrawColumnHeader 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 DrawListViewColumnHeaderEventArgs passed to the event handler contains information about the ColumnHeader to draw and also provides methods to help you draw the header.
Use the Header property to retrieve information about the column header to draw. 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 and DrawText 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 headers.
Note |
|---|
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.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
