Accesing dynamic Treeview nodes Please help me
can any one explain to me why this mouse up module is not working as I expected. there is some thing is wrong here I am unable to find. It is working only for 1 iteration then it is not showing any dailog box. Though while dubugging the code the curser going through the corresponding switch statement but I don't why it's not displaying even context menu.
Why so? How come dubugging is different to that of actual o/p
Please help me
thanks
[h]
private TreeNode m_OldSelectNode;
private TreeNode ParentNode;
private TreeNode Root;
private void treePanel_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
// Show menu only if the right mouse button is clicked.
if (e.Button == MouseButtons.Right)
{
// Point where the mouse is clicked.
Point p = new Point(e.X, e.Y);
// Get the node that the user has clicked.
TreeNode selnode = this.treePanel.GetNodeAt(p);
if (selnode != null)
{
// Select the node the user has clicked.
// The node appears selected until the menu is displayed on the screen.
m_OldSelectNode = treePanel.SelectedNode;
if (selnode.Level == 2)
{
ParentNode = selnode.Parent;
Root = ParentNode.Parent;
for (int i = 1; i <= pClass.Panels.Count; ++i)
{
InsightInterface.InsightPanelClass Panel = (InsightInterface.InsightPanelClass)pClass.Panels[i];
if ((Root != null) && (Panel.Name == Root.Text))
{
switch (Convert.ToString(selnode.Tag))
{
case "user":
for (int x = 1; x <= Panel.Users.Count; ++x)
{
InsightInterface.InsightUserClass user = (InsightInterface.InsightUserClass)Panel.Users[x];
if (user.Name == selnode.Text)
{
this.pSelUser = user;
ctxmnuUser.Show(treePanel, p);
addUserToolStripMenuItem.Visible = false;
return;
}
}
break;
case "usertype":
for (int x = 1; x <= Panel.UserTypes.Count; ++x)
{
InsightInterface.InsightUserTypeClass usertype = (InsightInterface.InsightUserTypeClass)Panel.UserTypes[x];
if (usertype.Name == selnode.Text)
{
this.pSelUserType = usertype;
ctxmnuUserTypes.Show(treePanel, p);
addUserTypesToolStripMenuItem.Visible = false;
return;
}
}
break;
case "timezone":
for (int x = 1; x <= Panel.timeZones.Count; ++x)
{
InsightInterface.IRTimeZoneClass timezone = (InsightInterface.IRTimeZoneClass)Panel.timeZones[x];
if (timezone.Name == selnode.Text)
{
this.pSelTimeZone = timezone;
ctxmnuTimeZones.Show(treePanel, p);
addTimeZoneToolStripMenuItem.Visible = false;
return;
}
}
break;
} // switch
} //if
} //for loop
}
if (selnode.Level == 1)
{
Root = selnode.Parent;
for (int i = 1; i <= pClass.Panels.Count; ++i)
{
InsightInterface.InsightPanelClass Panel = (InsightInterface.InsightPanelClass)pClass.Panels[i];
if ((Root != null) && (Panel.Name == Root.Text))
{
switch (Convert.ToString(selnode.Tag))
{
case "users":
this.pUsers = (InsightInterface.InsightUsersClass)Panel.Users;
ctxmnuUser.Show(treePanel, p);
editUserToolStripMenuItem.Visible = false;
break;
case "usertypes":
ctxmnuUserTypes.Show(treePanel, p);
editUserTypeToolStripMenuItem.Visible = false;
break;
case "timezones":
ctxmnuTimeZones.Show(treePanel, p);
editTimeZoneToolStripMenuItem.Visible = false;
break;
} //switch
} // if
} // for
} // if
}
// Highlight the selected node.
}
} // THE END
[/h]