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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. tree view node click event

tree view node click event

Scheduled Pinned Locked Moved Visual Basic
data-structuresquestion
9 Posts 3 Posters 1 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.
  • B Offline
    B Offline
    bhargava2409
    wrote on last edited by
    #1

    how can i fire a form through tree view node click event.

    D 1 Reply Last reply
    0
    • B bhargava2409

      how can i fire a form through tree view node click event.

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Create object of the form and use Show or ShowDialog method (as applicable).

      B 1 Reply Last reply
      0
      • D dan sh

        Create object of the form and use Show or ShowDialog method (as applicable).

        B Offline
        B Offline
        bhargava2409
        wrote on last edited by
        #3

        thanks for u r replay my problem is in the tree node selction program Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect Dim childnum, index As Int32 childnum = TreeView1.SelectedNode.GetNodeCount(False) index = TreeView1.SelectedNode.Index 'index = index + 1 If index = 0 Then Button2.Show() GroupBox1.Show() End If End Sub The Above function is not working for me to select tree node and fire,is there any thing wrong in tn my prg.

        J D 2 Replies Last reply
        0
        • B bhargava2409

          thanks for u r replay my problem is in the tree node selction program Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect Dim childnum, index As Int32 childnum = TreeView1.SelectedNode.GetNodeCount(False) index = TreeView1.SelectedNode.Index 'index = index + 1 If index = 0 Then Button2.Show() GroupBox1.Show() End If End Sub The Above function is not working for me to select tree node and fire,is there any thing wrong in tn my prg.

          J Offline
          J Offline
          Jon_Boy
          wrote on last edited by
          #4

          I'm not sure I'm completely following you here. The controls are displayed when the index is 1 right? What else are you expecting to occur? Also, check that you have at least 2 nodes in the treeview since the index is zero based.

          "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

          B 2 Replies Last reply
          0
          • B bhargava2409

            thanks for u r replay my problem is in the tree node selction program Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect Dim childnum, index As Int32 childnum = TreeView1.SelectedNode.GetNodeCount(False) index = TreeView1.SelectedNode.Index 'index = index + 1 If index = 0 Then Button2.Show() GroupBox1.Show() End If End Sub The Above function is not working for me to select tree node and fire,is there any thing wrong in tn my prg.

            D Offline
            D Offline
            dan sh
            wrote on last edited by
            #5

            TreeViewEventArgs has all the properties you need. You can use them right away. Apart from that what exactly is the problem you are facing.

            1 Reply Last reply
            0
            • J Jon_Boy

              I'm not sure I'm completely following you here. The controls are displayed when the index is 1 right? What else are you expecting to occur? Also, check that you have at least 2 nodes in the treeview since the index is zero based.

              "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

              B Offline
              B Offline
              bhargava2409
              wrote on last edited by
              #6

              I tried the aabove code by making a button visable false and on selcting a perticular treenode it will appear but the same code is not working for the group box that consits of some group of buttons. I want make that group box visable when i click on a perticular treeview node.

              1 Reply Last reply
              0
              • J Jon_Boy

                I'm not sure I'm completely following you here. The controls are displayed when the index is 1 right? What else are you expecting to occur? Also, check that you have at least 2 nodes in the treeview since the index is zero based.

                "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                B Offline
                B Offline
                bhargava2409
                wrote on last edited by
                #7

                I tried the aabove code by making a button visable false and on selcting a perticular treenode it will appear but the same code is not working for the group box that consits of some group of buttons. I want make that group box visable when i click on a perticular treeview node.One more thing i have i have 8 child nodes for my tree so thre is no problem of zero index base.

                J 1 Reply Last reply
                0
                • B bhargava2409

                  I tried the aabove code by making a button visable false and on selcting a perticular treenode it will appear but the same code is not working for the group box that consits of some group of buttons. I want make that group box visable when i click on a perticular treeview node.One more thing i have i have 8 child nodes for my tree so thre is no problem of zero index base.

                  J Offline
                  J Offline
                  Jon_Boy
                  wrote on last edited by
                  #8

                  Your code looks like it should work. Check the visible property (should be true) on the button controls in the group box to see if visible = true. If not, you'll need to change that at design time or during run time looping the groupbox's control collection. Quick test app you can do.

                  Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                      'add a group box and stuff with button controls 
                      For Each ctl As Control In GroupBox1.Controls 
                          ctl.Visible = True
                      Next
                  
                      GroupBox1.Visible = False
                  End Sub
                  
                  Private Sub TreeView1\_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
                      If e.Node.Index = 5 Then
                          GroupBox1.Visible = True
                      End If
                  End Sub
                  

                  "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                  B 1 Reply Last reply
                  0
                  • J Jon_Boy

                    Your code looks like it should work. Check the visible property (should be true) on the button controls in the group box to see if visible = true. If not, you'll need to change that at design time or during run time looping the groupbox's control collection. Quick test app you can do.

                    Private Sub Form1\_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                        'add a group box and stuff with button controls 
                        For Each ctl As Control In GroupBox1.Controls 
                            ctl.Visible = True
                        Next
                    
                        GroupBox1.Visible = False
                    End Sub
                    
                    Private Sub TreeView1\_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
                        If e.Node.Index = 5 Then
                            GroupBox1.Visible = True
                        End If
                    End Sub
                    

                    "There's no such thing as a stupid question, only stupid people." - Mr. Garrison

                    B Offline
                    B Offline
                    bhargava2409
                    wrote on last edited by
                    #9

                    Thanks Jon_Boy Your code is working for me. :)

                    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