Microsoft KB Archive/814734

= BUG: Subitems in a ListView control are displayed in incorrect colors and incorrect fonts =

Article ID: 814734

Article Last Modified on 5/16/2007

-

APPLIES TO


 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition
 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Visual C# .NET 2002 Standard Edition

-





SYMPTOMS
You have a Microsoft Windows form with a ListView control. The View property of the control is set to Details. You add an item, and then you set the Font property and the ForeColor property of the item. When you add subitems to this item, and then you set the Font and the ForeColor of the subitems to a different font and a different color, all the subitems in the ListView are displayed in the font and in the color that you set the parent item to. Also, when you run the application, and then you select the item in the ListView, all the subitems are displayed in the default font and the default color.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to Reproduce the Behavior

 * 1) In Microsoft Visual Studio .NET, start a new Windows application by using Microsoft Visual Basic .NET or Microsoft Visual C# .NET.

By default, Form1 is created.
 * 1) From the toolbox, drag a ListView control to Form1.
 * 2) Right-click ListView1, and then click Properties.
 * 3) In the Properties window, set the View property to Details.
 * 4) In the Properties window, click the Columns property, and then click the ellipsis button (...).
 * 5) In the ColumnHeader Collection Editor, click Add three times to add three columns, and then click OK.
 * 6) In the Properties window, click the Items property, and then click the ellipsis button.
 * 7) In the ListViewItem Collection Editor, click Add.
 * 8) Set the Text property of the ListView item to Item1.
 * 9) Set the ForeColor property of the ListView item to HotTrack.
 * 10) Click the SubItems property, and then click the ellipsis button.
 * 11) In the ListViewSubItem Collection Editor, click Add.
 * 12) Set the Text property to Item2.
 * 13) Set the ForeColor property to Menu.
 * 14) Click Add.
 * 15) Set the Text property to Item3.
 * 16) Set the ForeColor property to Info.
 * 17) Set the Font to Arial Black.
 * 18) In the ListViewSubItem Collection Editor, click OK.
 * 19) In the ListViewItem Collection Editor, click OK.

In ListView1, all the subitems appear in the color and in the font of the parent item. The color and the font that you set for the subitems are not stored.
 * 1) On the Debug menu, click Start.
 * 2) On the ListView control, click Item1.

The color of the subitems is changed to the default color.

