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