Subscribe to Subscribers
Talk to Webmaster Tony John

Online Members

Pawan Awasthi
More...


Resources » .NET programming » General

Treeview Control in WindowsForms Application


Posted Date:     Category: General    
Author: Member Level: Gold    Points: 15


This is the example for the Treeview Control and its some events which are usefull like AfterSelect and DoubleClick of mouse.Generally we saw TreeView type in our own systems like when you see folder you can see what files it contains on the left side when we search.



 


TreeView Control in Windows Forms Application.

Recently I saw a post many times regarding the treeview control how to show the selected node text, which event to use and how to double-click which event it fires. So here is the example for treeview.

Steps to do:
1) Take a new form and place the treeview control.
2) Select the dock property of the control and make it fill so it covers all the form empty space.
3) Now add the items in the structural way as in the below images. You use edit items in the smart tag of the treeview control (see below image).
4) Now goto the event and select AfterSelect event of the treeview which fires after selecting the node in the tree.
5) Now we will display the text of the node when it selects by using the below code

MessageBox.Show(treeView1.SelectedNode.Text.ToUpper());

6) Now you can check for the click event and doubleclick event also like

private void treeView1_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{
MessageBox.Show(treeView1.SelectedNode.Text.ToUpper()+"this is coming on double click of node.");
}


7) For expanding all the nodes in the starting itself you can use

private void treeview_Load(object sender, EventArgs e)
{
treeView1.ExpandAll();
}


Here this is small example you can try the same example like in the windows.

Attachments
  • TreeView in WindowsForms (44117-12316-TreeView-WindowsForms.rar)

    insertin itmes





  • Did you like this resource? Share it with your friends and show your love!


    Responses to "Treeview Control in WindowsForms Application"

    No responses found. Be the first to respond...

    Feedbacks      

    Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: SlideShow Example in the WindowsApplication
    Previous Resource: How to capture image using webcam in C#
    Return to Resources
    Post New Resource
    Category: General


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    (No tags found.)



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.