locked
Access to treeview of Main form RRS feed

  • Question

  • Hi,

    I have a main form A and a Treeview of menu in the form.

    using splitpanel, I set my Treeview1 on the left of the form and the panel2 for displaying of usercontrol1.  When I run my program, my treeview menu will be displayed on the left side and my usercontrol1 is on the right side.  If I call another usercontrol2 to view, replace for usercontrol1 and at this time I want to disable the treeview1, which mean the treeview is still there, but can not click on it...not activate.  

    How can I do that.  Please give some example line of codes.  Thanks,

    tt.

    Thursday, August 23, 2012 8:49 PM

Answers

  • Set the treeview enabled property to false.  The code example would be:
     
        treeview1.Enabled = false;
     

    --
    Mike
    • Proposed as answer by Bob Wu-MT Friday, August 24, 2012 3:02 AM
    • Marked as answer by Bob Wu-MT Tuesday, August 28, 2012 10:42 AM
    Friday, August 24, 2012 12:51 AM
  • Well,

    My problem is could not see variable treeview1 in my usercontrol1 so that I can code treeview1.Enabled = false; as above.

    However, I figured out how to fix it.

    Thanks for your help.

    tt.

    • Marked as answer by Bob Wu-MT Tuesday, August 28, 2012 10:43 AM
    Monday, August 27, 2012 3:27 PM

All replies

  • Set the treeview enabled property to false.  The code example would be:
     
        treeview1.Enabled = false;
     

    --
    Mike
    • Proposed as answer by Bob Wu-MT Friday, August 24, 2012 3:02 AM
    • Marked as answer by Bob Wu-MT Tuesday, August 28, 2012 10:42 AM
    Friday, August 24, 2012 12:51 AM
  • Well,

    My problem is could not see variable treeview1 in my usercontrol1 so that I can code treeview1.Enabled = false; as above.

    However, I figured out how to fix it.

    Thanks for your help.

    tt.

    • Marked as answer by Bob Wu-MT Tuesday, August 28, 2012 10:43 AM
    Monday, August 27, 2012 3:27 PM
  • I had presumed you were trying this from the form code, not from the usercontrol1.  To do this from the usercontrol, you would 1) need an instance of the main form, and 2) have set treeview1 as a public property so that it accessible outside the form.  In general, part 2 is not advisable.
     
    Glad you solved it though.

    --
    Mike
    Monday, August 27, 2012 10:10 PM