我有具有不同级别 TreeNodes 的 TreeView
我向所有父 TreeNodes 添加了相同的 ContextMenuStrip,我希望通过打开该 ContextMenuStrip 并按“全部删除”来删除所有子 TreeNodes
private void btn_delete_all_objects_Click(object sender, EventArgs e)
{
ToolStripMenuItem tsmi = (ToolStripMenuItem)sender; //that way i receive button "Delete all"
ContextMenuStrip cms = (ContextMenuStrip)tsmi.Owner; //this is ContextMenuStrip where this button...
TreeView tw = (TreeView)cms.SourceControl; //i can get TreeView :( BUT I NEED TreeNode!
TreeNode tn = tw.SelectedNode; //bah... if i select some of child nodes, then right click to open menu on parent, selected node is still that child
}
而且我不知道如何获取用户单击以打开菜单的 TreeNode 有
什么想法吗?