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. Fire AfterSelection event

Fire AfterSelection event

Scheduled Pinned Locked Moved C#
data-structureshelpquestion
6 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.
  • E Offline
    E Offline
    eyalle
    wrote on last edited by
    #1

    Hello, i have a tree view ,were an After Selection event occurs after selecting a node. i also have a function called refresh which refreshes the tree View by building it from scratch. the problem is that when the refresh is made, the selected node is not changing, which is fine, but the after Select event is not fired, which is not fine at all (since this event retrieves necessary data). my question is: how (if possible) can i fire an after Selection event without changing my selection. attached is relevant code Thanks

    private void tvwProject_AfterSelect(object sender, TreeViewEventArgs e)
    ...

    //this code mainly constructs the tree View

    private void refreshProjectTree()
    {
    if (isProject)
    {
    BLFunctions.BuildProjectTree(tvwProject);
    BLFunctions.ExpandNode(tvwProject, tvwProject.Nodes[0]);
    }
    else
    {
    BLFunctions.BuildSchemaTree(tvwSchema);
    }
    }

    C 1 Reply Last reply
    0
    • E eyalle

      Hello, i have a tree view ,were an After Selection event occurs after selecting a node. i also have a function called refresh which refreshes the tree View by building it from scratch. the problem is that when the refresh is made, the selected node is not changing, which is fine, but the after Select event is not fired, which is not fine at all (since this event retrieves necessary data). my question is: how (if possible) can i fire an after Selection event without changing my selection. attached is relevant code Thanks

      private void tvwProject_AfterSelect(object sender, TreeViewEventArgs e)
      ...

      //this code mainly constructs the tree View

      private void refreshProjectTree()
      {
      if (isProject)
      {
      BLFunctions.BuildProjectTree(tvwProject);
      BLFunctions.ExpandNode(tvwProject, tvwProject.Nodes[0]);
      }
      else
      {
      BLFunctions.BuildSchemaTree(tvwSchema);
      }
      }

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Factor the code out to a method you call at the end of your refresh method.

      Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

      E 1 Reply Last reply
      0
      • C Christian Graus

        Factor the code out to a method you call at the end of your refresh method.

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        E Offline
        E Offline
        eyalle
        wrote on last edited by
        #3

        Hi Christian, could you be more specific ? i couldn't understand what you mean by your answer.

        C 1 Reply Last reply
        0
        • E eyalle

          Hi Christian, could you be more specific ? i couldn't understand what you mean by your answer.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          It's painfully obvious. you have some code inside an event, that you need to run in a situation where the event does not fire. So take this code, move it to a new method, and then call this method from your event, and from the method which you were hoping would fire this event. And buy a basic book like 'Code Complete', and read it.

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          E 1 Reply Last reply
          0
          • C Christian Graus

            It's painfully obvious. you have some code inside an event, that you need to run in a situation where the event does not fire. So take this code, move it to a new method, and then call this method from your event, and from the method which you were hoping would fire this event. And buy a basic book like 'Code Complete', and read it.

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            E Offline
            E Offline
            eyalle
            wrote on last edited by
            #5

            Ok mr.Graus so if you say so, how would i get the TreeViewEventArgs if im calling a method where no such args are sent to it ?!?!?!?

            L 1 Reply Last reply
            0
            • E eyalle

              Ok mr.Graus so if you say so, how would i get the TreeViewEventArgs if im calling a method where no such args are sent to it ?!?!?!?

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You could build an instance of TreeViewEventArgs using tvwProjects.SelectedNode and pass it to the factored method.

              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