Microsoft KB Archive/822480

= BUG: TreeView fisplays node icons display after the images are removed from the ImageList =

Article ID: 822480

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 may have a Windows Form with a TreeView control that is associated with an ImageList control. This permits the display of icons next to each node. The icons are positioned to the immediate left of the node text. When you remove the image from the ImageList control, you can see that the icons that are next to each node are not removed.



CAUSE
This problem occurs because the Form is not repainted after you remove the images from the ImageList. Therefore, images in the TreeView control still appear.



RESOLUTION
To resolve the problem, close the Form designer, reopen the Form, and then follow these steps:
 * 1) Close the Form designer.
 * 2) Click Yes to save to the form in Microsoft Development Environment.
 * 3) In Solution Explorer, right-click Form1.vb or Form1.cs, and then click Open. You see that the images are removed from the TreeView control.



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 Problem

 * 1) In Microsoft Visual Studio .NET, create a new Microsoft Windows application. You can use either Visual Basic .NET or Visual C# .NET.

By default, Form1 is created.
 * 1) From the Toolbox, drag a TreeView control to Form1.
 * 2) Right-click TreeView1, and then click Properties.
 * 3) In the Properties window, click the Nodes property, and then click the ellipsis (...).
 * 4) In the TreeNode editor, click Add Root three times, and then click OK.
 * 5) From the Toolbox, drag an ImageList control to Form1.
 * 6) In the Properties window of ImageList1, click the Images property, and then click ....
 * 7) In Image Collection Editor, click Add.
 * 8) In the Open dialog box, move to the folder that is named arrows. Use the following path:

%Program Files%\Microsoft Visual Studio .NET\Common7\Graphics\icons\arrows

Select an .ico file, and then click Open.

Note If you use Visual Studio .NET 2003, select an .ico file from the folder at the following path:

%Program Files%\Microsoft Visual Studio .NET 2003\Common7\Graphics\icons\arrows
 * 1) In Image Collection Editor, click OK.
 * 2) In the Properties window for TreeView1, set the ImageList property to ImageList1.
 * 3) In the Properties window for ImageList1, click the Images property, and then click ....
 * 4) In Image Collection Editor, click Remove, and then click OK.
 * 5) You see that the images that are in the TreeView control (TreeView1) are not removed.

