BUG: Node element does not paint after you call the EndUpdate method (814354)
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)
SYMPTOMSIn a Microsoft Visual Studio .NET Windows application, you
call the Nodes.Clear method to clear the nodes of a TreeView control before you call
the TreeView.endUpdate method. The first node added after TreeView.EndUpdate does not paint until you add the second node.CAUSEWhen you call the EndUpdate method, a WM_SETREDRAW message is delivered to redraw the nodes
of the TreeView control. When you call Nodes.Clear before EndUpdate, the WM_SETREDRAW message sets the number of nodes in TreeView to
-1 instead of 0. When you add the first node
element, the node count is incremented to 0 instead of
1. Therefore, the TreeView node is not painted. When you add a
second node, the node count is incremented to 1, the paint
method is called, and the node count is correctly updated to
2. This causes both the nodes to be painted.WORKAROUNDTo work around this problem, add a node to the TreeView, and
then send a WM_SETREDRAW message to reset the node count to 1
instead of 0. To do this, call the Nodes.Add method between the BeginUpdate method and the EndUpdate method, as follows: Visual Basic .NETTreeView1.BeginUpdate()
TreeView1.Nodes.Add("test")
TreeView1.EndUpdate() Visual C# .NETtreeView1.BeginUpdate();
treeView1.Nodes.Add("test") ;
treeView1.EndUpdate(); STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
Modification Type: | Minor | Last Reviewed: | 1/20/2006 |
---|
Keywords: | kbvs2005doesnotapply kbvs2005swept kbvs2002sp1sweep kbTreeView kbControl kbComCtrls kbbug KB814354 kbAudDeveloper |
---|
|