This is a migrated thread and some comments may be shown as answers.

Node Removing event?

1 Answer 145 Views
Treeview
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 06 Jan 2013, 09:52 PM
I have a variety of actions that need to take place prior to NodeRemoved event firing.  I will typically use the Gridview_RowsChanging, NotifyCollectionChangedAction.Replace or NotifyCollectionChangedAction.Remove (as an example) which work well and I'm looking for something similar to capture the action of a treeview  context menu (Add/Delete).

Any thoughts?

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 09 Jan 2013, 02:39 PM
Hi Scott,

Thank you for writing.

Currently, there is not such event in RadTreeView. The available events will fire once the node is removed from the Nodes collection. There is a feature request for such in our Public Issue Tracking System. Feel free to add your vote for it here: http://www.telerik.com/support/pits.aspx#/details/Issue=10268.

What I can offer is to subscribe to the click event of the &Delete menu item in the context menu and perform the logic there, even though the node will no longer be in the Nodes collection. If you want to access this node, you can save it when the context menu is being opened:
RadTreeNode saveNode;
 
void radTreeView1_ContextMenuOpening(object sender, TreeViewContextMenuOpeningEventArgs e)
{
    foreach (RadMenuItem item in e.Menu.Items)
    {
        if (item.Text == "&Delete")
        {
            saveNode = e.Node;
            item.Click -= item_Click;
            item.Click += item_Click;
        }
    }
}
 
void item_Click(object sender, EventArgs e)
{
    //delete option from context menu is pressed
}


All the best,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
Treeview
Asked by
Scott
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or