By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,009 Members | 1,487 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,009 IT Pros & Developers. It's quick & easy.

diff. context menu for root and children

P: 153
I have got one tree tree view control.I have three levels in it.


How would i have a diff context menu for dif levels ?
I mean if i click the roots i should have one context menu and when the chldren a diff context menu and when child of child a diff context menu.
Tha's because the meaning of diff types(based on level) is diff.

Jan 4 '09 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 221
The TreeNode object has a ContextMenu and ContextMenuStrip property that can be used for setting the context menu for the individual node. The context menu can be different for each node if that's what you need, just set it when you create the nodes.
Jan 5 '09 #2

P: 153
well i did this
private void treeexchange_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
if (e.Button == MouseButtons.Right)
treeexchange.SelectedNode = e.Node;

if (e.Node.Text == "Extensions")
cmsextensions.Show(treeexchange,e.Location );
else if (e.Node.Text == "Trunks")
cmstrunks.Show(treeexchange, e.Location);
cmspbx.Show(treeexchange, e.Location);

else if (e.Node.Parent != null && e.Node.Parent.Parent == null)
if (e.Node.Parent.Text == "Extensions")
cmsgroups.Show(treeexchange, e.Location);
cmstrunk.Show(treeexchange, e.Location);
cmsextension.Show(treeexchange, e.Location);

I created diff CMS for each level's nodes.
There are only three levels so it worked.
Definitely not the best but was ok for me.
Jan 6 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.