title: Treeview control in SharePoint - doesn't refresh when I update web part properties
body: <p>I'm trying to create a web part that contains a TreeView control. I've  got a Web Part bool property called MyCheckbox and I use this to determine which nodes should appear in the Treeview.</p>
  
  <p>The problem I'm having is that when I modify the property exposed in the Web Part Properties ("Modify Shared Web Part.."), the MyCheckBox bool, and hit 'OK', the Treeview doesn't refresh. However, if I then browse to the page, the treeview is updated.</p>
  
  <p>I am declaring the class as follows, using the Treeview and its root node as member variables:</p>
  
  <pre><code>public class MyWebPart : System.Web.UI.WebControls.WebParts.WebPart
  {
      private TreeView tree = new TreeView();
      private TreeNode rootNode; 
  
      [WebBrowsable(true)]    
      [Personalizable(PersonalizationScope.Shared)]
      public bool MyCheckBox
      {
          get { return _myCheckBox; }
          set { _myCheckBox = value; } 
      }
  
      private bool __myCheckBox = false;
  
  
      public MyWebPart()
      {
      }
  
      public override void RenderControl(HtmlTextWriter writer)
      {
          tree.RenderControl(writer);
      }
  
      protected override void CreateChildControls()
      {
          rootNode = new TreeNode("ExampleRootNode");
  
          for ( int x = 0; x &lt; 3; x++) 
          {
              TreeNode listNode = new TreeNode(x.ToString());
              rootNode.ChildNodes.Add(listNode);
          }
  
          if (_myCheckBox) 
          { 
              TreeNode listNode = new TreeNode("Final entry");
              rootNode.ChildNodes.Add(listNode);
          }
  
          tree.Nodes.Add(rootNode);
          this.Controls.Add(tree);           
      }
  
      protected override void Render(HtmlTextWriter writer)
      {           
          base.Render(writer);
      }
  }
  </code></pre>
  
  <p>I've tried checking postback, clearing the list, and a million other things. I'm sure I must be missing something! </p>