We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Delete Node

Thread ID:

Created:

Updated:

Platform:

Replies:

15238 Jun 15,2004 06:46 AM Jun 17,2004 05:13 AM Windows Forms 5
loading
Tags: Tools
Satish
Asked On June 15, 2004 06:46 AM

Hi Guru, How can i delete a current selected node at run time? I didnt find any function like treeview.DeleteNode(index).... something like this???? Thanks Satish

Administrator [Syncfusion]
Replied On June 15, 2004 08:24 AM

Hi Satish, Please try this this.treeViewAdv1.Nodes.Remove(this.treeViewAdv1.SelectedNode); Let me know if you have any questions. Thanks. Best regards, Stephen. >Hi Guru, >How can i delete a current selected node at run time? I didnt find any function like treeview.DeleteNode(index).... something like this???? >Thanks >Satish

Satish
Replied On June 15, 2004 09:11 PM

Hi Stephen, But the problem in this is, it never deletes the selected row, It will delete the previous selected row if you are using Context Menu to delete the row. Thanks Satish >Hi Satish, > >Please try this > >this.treeViewAdv1.Nodes.Remove(this.treeViewAdv1.SelectedNode); > >Let me know if you have any questions. Thanks. > >Best regards, > >Stephen. > >>Hi Guru, >>How can i delete a current selected node at run time? I didnt find any function like treeview.DeleteNode(index).... something like this???? >>Thanks >>Satish

Satish
Replied On June 15, 2004 11:21 PM

Hi Stephen Please find the document that explains in clear. Thanks Satish >Hi Stephen, >But the problem in this is, it never deletes the selected row, It will delete the previous selected row if you are using Context Menu to delete the row. >Thanks >Satish > >>Hi Satish, >> >>Please try this >> >>this.treeViewAdv1.Nodes.Remove(this.treeViewAdv1.SelectedNode); >> >>Let me know if you have any questions. Thanks. >> >>Best regards, >> >>Stephen. >> >>>Hi Guru, >>>How can i delete a current selected node at run time? I didnt find any function like treeview.DeleteNode(index).... something like this???? >>>Thanks >>>Satish DeleteNodeProblem_8093.zip

Administrator [Syncfusion]
Replied On June 16, 2004 08:05 PM

Hi Satish, This line of code: this.treeViewAdv1.Nodes.Remove(this.treeViewAdv1.SelectedNode); will only delete the selected node if it is a root node as TreeViewAdv.Nodes returns the collection of nodes at level 0. The Nodes collection does not contain all the nodes of the tree, but just the level 0 nodes. If the node is in a level greater than 0, it is not deleted as it is not contained in the primary Nodes collection. So you instead call: TreeViewAdv.SelectedNode.Parent.Nodes.Remove(TreeViewAdv.SelectedNode) Refer to the TreeViewAdvDemo sample (Tools\samples\Tree Package\TreeViewAdvDemo). This sample shows how you can use a context menu in conjunction with the TreeViewAdv control. Here is code you can add to the Cut context menu to take care of what you are looking for: private void cutItem_Click(object sender, System.EventArgs e) { //MessageBox.Show("Not Implemented. Only Edit menu is implemented."); this.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(this.treeViewAdv1.SelectedNode); } Regards Arun

Satish
Replied On June 17, 2004 05:13 AM

Hi Arun, I think you didnt get what I was saying. Anyway I have done this using the following code. //Assign the Selected Node tree.SelectedNode = tree.RMouseDownNode; Thanks Satish >Hi Satish, > >This line of code: >this.treeViewAdv1.Nodes.Remove(this.treeViewAdv1.SelectedNode); >will only delete the selected node if it is a root node as TreeViewAdv.Nodes returns the collection of nodes at level 0. The Nodes collection does not contain all the nodes of the tree, but just the level 0 nodes. If the node is in a level greater than 0, it is not deleted as it is not contained in the primary Nodes collection. So you instead call: > >TreeViewAdv.SelectedNode.Parent.Nodes.Remove(TreeViewAdv.SelectedNode) > > >Refer to the TreeViewAdvDemo sample (Tools\samples\Tree Package\TreeViewAdvDemo). This sample shows how you can use a context menu in conjunction with the TreeViewAdv control. > >Here is code you can add to the Cut context menu to take care of what you are looking for: >private void cutItem_Click(object sender, System.EventArgs e) >{ >//MessageBox.Show("Not Implemented. Only Edit menu is implemented."); >this.treeViewAdv1.SelectedNode.Parent.Nodes.Remove(this.treeViewAdv1.SelectedNode); >} > >Regards >Arun

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;