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. General Programming
  3. C#
  4. calling forms from treeview nodes

calling forms from treeview nodes

Scheduled Pinned Locked Moved C#
tools
4 Posts 3 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.
  • M Offline
    M Offline
    Mamphekgo Bahula
    wrote on last edited by
    #1

    Hi i want select a node from treeview nodes and call the form that i have selected its node. here is my code. node1 = "Company"; node2 = "Process"; node3 = "Script"; node4 = "Group"; node5 = "User"; if (node1 == "Company" ) { cmsCompany.Show(); } else if (node2 == "Process") { cmsProcess.Show(); } else if (node3 == "Script") { cmsScript.Show(); } else if (node4 == "Group") { cmsGroup.Show(); } else if (node5 == "User") { cmsUser.Show(); }

    Mamphekgo

    M 1 Reply Last reply
    0
    • M Mamphekgo Bahula

      Hi i want select a node from treeview nodes and call the form that i have selected its node. here is my code. node1 = "Company"; node2 = "Process"; node3 = "Script"; node4 = "Group"; node5 = "User"; if (node1 == "Company" ) { cmsCompany.Show(); } else if (node2 == "Process") { cmsProcess.Show(); } else if (node3 == "Script") { cmsScript.Show(); } else if (node4 == "Group") { cmsGroup.Show(); } else if (node5 == "User") { cmsUser.Show(); }

      Mamphekgo

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, I think the 'AfterSelect' event will help you. //Constructor code yourTreeView.AfterSelect+=new TreeViewEventHandler(yourTreeView_AfterSelect); private void yourTreeView_AfterSelect(object sender, TreeViewEventArgs e) { switch(yourTreeView.SelectedNode.Text) { case "Company": cmsCompany.Show(); break; case "Process": cmsProcess.Show(); break; case "Script": cmsScript.Show(); break; default: break; } }

      All the best, Martin

      P 1 Reply Last reply
      0
      • M Martin 0

        Hello, I think the 'AfterSelect' event will help you. //Constructor code yourTreeView.AfterSelect+=new TreeViewEventHandler(yourTreeView_AfterSelect); private void yourTreeView_AfterSelect(object sender, TreeViewEventArgs e) { switch(yourTreeView.SelectedNode.Text) { case "Company": cmsCompany.Show(); break; case "Process": cmsProcess.Show(); break; case "Script": cmsScript.Show(); break; default: break; } }

        All the best, Martin

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Whenever I see code like this, it makes me think that there's a Factory missing somewhere (and I'm not having a go at your code here - it's the OP requirement that is prompting me here). I hope that he's managing his form disposal as well, but I bet that he isn't.

        Deja View - the feeling that you've seen this post before.

        M 1 Reply Last reply
        0
        • P Pete OHanlon

          Whenever I see code like this, it makes me think that there's a Factory missing somewhere (and I'm not having a go at your code here - it's the OP requirement that is prompting me here). I hope that he's managing his form disposal as well, but I bet that he isn't.

          Deja View - the feeling that you've seen this post before.

          M Offline
          M Offline
          Martin 0
          wrote on last edited by
          #4

          Hello Pete,

          Pete O`Hanlon wrote:

          it makes me think that there's a Factory missing somewher

          So true!!! (Got my 5 for that)

          Pete O`Hanlon wrote:

          I hope that he's managing his form disposal as well

          You are write, I should allways point this out at answers.

          Pete O`Hanlon wrote:

          but I bet that he isn't.

          Let's wait and see, what he is answering.

          All the best, Martin

          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