BUG: TreeView fisplays node icons display after the images are removed from the ImageList (822480)



The information in this article applies to:

  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)
  • Microsoft Visual C# .NET (2003)
  • Microsoft Visual C# .NET (2002)

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 "Applies to" section.

MORE INFORMATION

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.
  2. From the Toolbox, drag a TreeView control to Form1.
  3. Right-click TreeView1, and then click Properties.
  4. In the Properties window, click the Nodes property, and then click the ellipsis (...).
  5. In the TreeNode editor, click Add Root three times, and then click OK.
  6. From the Toolbox, drag an ImageList control to Form1.
  7. In the Properties window of ImageList1, click the Images property, and then click ....
  8. In Image Collection Editor, click Add.
  9. 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
  10. In Image Collection Editor, click OK.
  11. In the Properties window for TreeView1, set the ImageList property to ImageList1.
  12. In the Properties window for ImageList1, click the Images property, and then click ....
  13. In Image Collection Editor, click Remove, and then click OK.
  14. You see that the images that are in the TreeView control (TreeView1) are not removed.

REFERENCES

For more information about the Windows Forms TreeView control, visit the following Microsoft Web site:

http://msdn.microsoft.com/library/en-us/vbcon/html/vbcontreeviewcontroloverview.asp

Modification Type:MinorLast Reviewed:2/3/2006
Keywords:kbvs2005swept kbvs2005doesnotapply kbvs2002sp1sweep kbDesigner kbWindowsForms kbCtrl kbControl kbImgList kbTreeView kbbug KB822480 kbAudDeveloper