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. Treeview doesn't update after treenode.remove

Treeview doesn't update after treenode.remove

Scheduled Pinned Locked Moved C#
databasehelpquestionannouncement
8 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

    I've written the following code to remove a node from a treeview. The node data isremoved, butthe node is still there. Apparently I need to force a refresh, as the selected node does go away when I navigate away and back to the page. Can anyone help? Thanks Eyal

    //removes the node from the DB
    int remove = SchemaDB.DeleteGenericLink(originNode.Tag),TargetNode.Tag);

                if (remove)
                {
                    originNode.Remove();                   
                }
    

    //this if, doesnt remove the originNode from the targetNode.Nodes

    L B 2 Replies Last reply
    0
    • E eyalle

      I've written the following code to remove a node from a treeview. The node data isremoved, butthe node is still there. Apparently I need to force a refresh, as the selected node does go away when I navigate away and back to the page. Can anyone help? Thanks Eyal

      //removes the node from the DB
      int remove = SchemaDB.DeleteGenericLink(originNode.Tag),TargetNode.Tag);

                  if (remove)
                  {
                      originNode.Remove();                   
                  }
      

      //this if, doesnt remove the originNode from the targetNode.Nodes

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      is this code executing on the main thread? if not, you're in trouble. see this[^]. :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


      Merry Christmas and a Happy New Year to all.


      E 1 Reply Last reply
      0
      • L Luc Pattyn

        is this code executing on the main thread? if not, you're in trouble. see this[^]. :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


        Merry Christmas and a Happy New Year to all.


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

        i have only one thread. so i guess it does runs from the main thread..

        L 1 Reply Last reply
        0
        • E eyalle

          i have only one thread. so i guess it does runs from the main thread..

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          eyalle wrote:

          i guess

          not very scientific; you could check using Control.InvokeRequired or by looking at Thread.GetCurrentThread().ThreadID.

          eyalle wrote:

          i have only one thread. so ...

          unless you have asynchronous handlers, moat of them run from a threadpool thread (most timers, SerialPort.DataReceived, etc). :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


          Merry Christmas and a Happy New Year to all.


          1 Reply Last reply
          0
          • E eyalle

            I've written the following code to remove a node from a treeview. The node data isremoved, butthe node is still there. Apparently I need to force a refresh, as the selected node does go away when I navigate away and back to the page. Can anyone help? Thanks Eyal

            //removes the node from the DB
            int remove = SchemaDB.DeleteGenericLink(originNode.Tag),TargetNode.Tag);

                        if (remove)
                        {
                            originNode.Remove();                   
                        }
            

            //this if, doesnt remove the originNode from the targetNode.Nodes

            B Offline
            B Offline
            Ben Fair
            wrote on last edited by
            #5

            The easiest thing would be to call the TreeView.Invalidate() to have it redraw itself.

            Hold on a second here... Don't you think you might be putting the horse ahead of the cart?

            E 1 Reply Last reply
            0
            • B Ben Fair

              The easiest thing would be to call the TreeView.Invalidate() to have it redraw itself.

              Hold on a second here... Don't you think you might be putting the horse ahead of the cart?

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

              what to you mean by putting the horse ahead of the cart?

              B 1 Reply Last reply
              0
              • E eyalle

                what to you mean by putting the horse ahead of the cart?

                B Offline
                B Offline
                Ben Fair
                wrote on last edited by
                #7

                That's from my signature, it's not related to your inquiry. However, there is a saying in the United States (and perhaps other English-speaking countries) of "putting the cart ahead of the horse" in other words, doing things in the wrong order. I just reversed them to where they are back in the correct order because I'm a goofball. :laugh:

                Hold on a second here... Don't you think you might be putting the horse ahead of the cart?

                E 1 Reply Last reply
                0
                • B Ben Fair

                  That's from my signature, it's not related to your inquiry. However, there is a saying in the United States (and perhaps other English-speaking countries) of "putting the cart ahead of the horse" in other words, doing things in the wrong order. I just reversed them to where they are back in the correct order because I'm a goofball. :laugh:

                  Hold on a second here... Don't you think you might be putting the horse ahead of the cart?

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

                  Got'ya.. anyway, your solution isnt working. i'll tell you what i found out maybe you'll know in my code where i do

                  originNode.Remove();

                  the

                  targetNode.Nodes.Count

                  doesnt change.. for Example, if i had 2 nodes under the targetNode, after the Remove function, still staying with 2..

                  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