Microsoft KB Archive/283019

= BUG: Application Fails When You Check TreeView Node Before the TreeView Control Is Displayed =

Article ID: 283019

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition

-



This article was previously published under Q283019



SYMPTOMS
When you call the setChecked(true) method on a TreeView node, the call may fail if the TreeView control has not yet been displayed.



CAUSE
This problem occurs because the control is not created until it is displayed.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 In Visual J++ 6.0, create a new Windows application. Add a TabControl to the form, and create two TabPages. To create TabPages, follow these steps:  In the Properties window, select the tabs property. In the TabPage[] Editor window, create two TabPages.  In the second TabPage, add a TreeView control and a few CheckBox nodes. To create CheckBox nodes, follow these steps:  In the Properties window, change the CheckBoxes property to true.</li> Select the nodes property.</li> In the TreeNode Editor window, add two root nodes.</li></ul> </li> In the first TabPage, add two buttons.</li>  Add two button event handlers to programmatically call the setChecked method as follows: private void button1_click(Object source, Event e) { TreeNode treenode = treeView1.getNode(0); treenode.setChecked(true); }

private void button2_click(Object source, Event e) { TreeNode treenode = treeView1.getNode(0); treenode.setChecked(false); }                   </li> Run the application. You cannot use the buttons on the first TabPage to control the state of the check box items in the TreeView control on the second TabPage.

However, when you select the second TabPage to bring the TreeView control into view when the application comes up, you can use the buttons on the first TabPage to control the state of the check box items.</li></ol>

<div class="references_section">