Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    API(s)
    Sencha-Touch
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> ASP.Net & Web Forms >> Expandable TreeView Node in C#
Expandable TreeView Node in C#
Expandable TreeView Node in C#


by zhang wei on 4/2/2012 2:25:42 PM

Views: 1735       Comments: 2

Expandable TreeView Node in C#

In this article I’m going to explain how to make expandable treeview node in C# when others node is closed. Here I’m just creating a method to perform this task with name TreeView1_TreeNodeExpanded. Let’s take a look of this method code:

Foreground code:

<asp:TreeView ID="TreeView1" runat="server" ExpandDepth="0" OnTreeNodeExpanded="TreeView1_TreeNodeExpanded" ShowLines="True">

Code-behind:

protected void TreeView1_TreeNodeExpanded(object sender, TreeNodeEventArgs e)

         {

              TreeNodeCollection ts = null;

             if (e.Node.Parent == null)

             {

                 ts = ((TreeView)sender).Nodes;

             }

             else

                 ts = e.Node.Parent.ChildNodes;

             foreach (TreeNode node in ts)

             {

                 if (node != e.Node)

                 {

                     node.Collapse();

                 }

             }

         }

 

Thanks for showing your interest in this article.

 

Report Abuse Form
Reason:    
 


Expandable TreeView Node in C#
by Haider M Rizvi 4/2/2012 8:13:16 AM
Hi zhang wei,

Welcome to our MindStick Developers Section. Here you can share your knowledge to help others.

You cannot upload same content in more than one section, if its done then only one of them will be approved.

Looking forward for more Articles/Blogs from your side.

Thanks.
Report Abuse

Haider M Rzvi
by zhang wei 4/3/2012 3:56:05 AM

Hi Haider M Rzvi,thank you for help me,my english not well ,I belive i can to do more better!

I very Thanks!

Report Abuse
Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by zhang weiRSS Feed
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 2612
Advertisement
MindStick Cleaner
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.