Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Treeview Expand and Collapse

Treeview Expand and Collapse

Scheduled Pinned Locked Moved ASP.NET
help
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Krishhhhhhhhhhhhhh
    wrote on last edited by
    #1

    Hi all. Am developing a web application. In that i placed a treeview. Now My requirement is : When i click on any node it should expand and already expanded nodes should be collapsed. Please help me.

    S 1 Reply Last reply
    0
    • K Krishhhhhhhhhhhhhh

      Hi all. Am developing a web application. In that i placed a treeview. Now My requirement is : When i click on any node it should expand and already expanded nodes should be collapsed. Please help me.

      S Offline
      S Offline
      specialdreamsin
      wrote on last edited by
      #2

      Hi, You have to write code like this, Protected Sub TvwPages_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TvwPages.SelectedNodeChanged             If TvwPages.SelectedNode.Text = "Screens" Then                   If TvwPages.Nodes.Count > 1 Then                         TvwPages.Nodes(1).Collapse() 'Collapse Reports                   End If                   TvwPages.Nodes(0).Expand() 'Expand Screens             ElseIf TvwPages.SelectedNode.Text = "Reports" Then                   If TvwPages.Nodes.Count > 1 Then                         TvwPages.Nodes(0).Collapse() 'Collapse Screens                   End If                   TvwPages.Nodes(1).Expand() 'Expand Reports             End If End Sub If you have more than one Tree View item, Use this line ,( PUT in a For Loop) till List Count                      TvwPages.Nodes(i).Collapse() Ramesh Sambari

      K 1 Reply Last reply
      0
      • S specialdreamsin

        Hi, You have to write code like this, Protected Sub TvwPages_SelectedNodeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TvwPages.SelectedNodeChanged             If TvwPages.SelectedNode.Text = "Screens" Then                   If TvwPages.Nodes.Count > 1 Then                         TvwPages.Nodes(1).Collapse() 'Collapse Reports                   End If                   TvwPages.Nodes(0).Expand() 'Expand Screens             ElseIf TvwPages.SelectedNode.Text = "Reports" Then                   If TvwPages.Nodes.Count > 1 Then                         TvwPages.Nodes(0).Collapse() 'Collapse Screens                   End If                   TvwPages.Nodes(1).Expand() 'Expand Reports             End If End Sub If you have more than one Tree View item, Use this line ,( PUT in a For Loop) till List Count                      TvwPages.Nodes(i).Collapse() Ramesh Sambari

        K Offline
        K Offline
        Krishhhhhhhhhhhhhh
        wrote on last edited by
        #3

        Hi this is good for selecting child nodes. because "SelectedNodeChanged" event hires when child node is selected. But I want when Parent node is selected it should be expanded and if any expanded nodes are there they should be collapsed. Plz help me Its urgent

        S 1 Reply Last reply
        0
        • K Krishhhhhhhhhhhhhh

          Hi this is good for selecting child nodes. because "SelectedNodeChanged" event hires when child node is selected. But I want when Parent node is selected it should be expanded and if any expanded nodes are there they should be collapsed. Plz help me Its urgent

          S Offline
          S Offline
          specialdreamsin
          wrote on last edited by
          #4

          Hi, Try Using this.... Protected Sub TvwPages_TreeNodeExpanded(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.TreeNodeEventArgs) Handles TvwPages.TreeNodeExpanded             If e.Node.Text = "Screens" And TvwPages.Nodes.Count > 1 Then                   TvwPages.Nodes(1).Collapse()             End If             If e.Node.Text = "Reports" And TvwPages.Nodes.Count > 1 Then                   TvwPages.Nodes(0).Collapse()             End If End Sub and..one thing...never say URGENT. It is completely irrelevent to others. Ramesh Sambari

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups