UseItemStyleForSubItems Property

ListViewItem.UseItemStyleForSubItems Property


Gets or sets a value indicating whether the Font, ForeColor, and BackColor properties for the item are used for all its subitems.

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

public bool UseItemStyleForSubItems { get; set; }

Property Value

Type: System.Boolean

true if all subitems use the font, foreground color, and background color settings of the item; otherwise, false. The default is true.

If you do not want to have a uniform background color, foreground color, and font used for all items and subitems in your ListView control, you can set this property to false. When this property is set to true, any changes made to the subitem's ListViewItem.ListViewSubItem.Font, ListViewItem.ListViewSubItem.ForeColor, and ListViewItem.ListViewSubItem.BackColor properties are ignored, and the values of the item are used instead. You can use this property if you need to specify a different text color, background color, or font to be used for a subitem to highlight the item when subitems are displayed in the ListView control.

The following code example demonstrates how to set the UseItemStyleForSubItems property to false to define a custom style for ListViewItem.ListViewSubItem objects. The example also demonstrates how to set the ForeColor and Font properties. To run the example, paste the following code into a form and call the InitializeListView method in form's constructor or Load event-handling method.

Snippet section 1 of code snippet {"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"12124e67-6e1c-4477-8d8c-e9bed6b9ca80","entity_type":"CodeSnippet","locale":"en-US"} in source file ({"filename":"/CS/form1.cs","blob_type":"Source","blob_id":"-002fcs-002fform1-002ecs","blob_revision":2}) overlaps with other snippet sections. Ensure the tags are placed correctly.

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft