private void btnAddNode_Click(object sender, EventArgs e) { PxMenuSelection selectedMenu = (PxMenuSelection)tvMenuSelection.SelectedNode.Tag; int levelNo; int.TryParse(selectedMenu.LevelNo, out levelNo); if (levelNo < 4) { CreateMenuSelectionDialog frmCreateDialog = new CreateMenuSelectionDialog(); frmCreateDialog.NewMenuSelection.Parent = selectedMenu; frmCreateDialog.NewMenuSelection.LevelNo = (levelNo + 1).ToString(); if (frmCreateDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { selectedMenu.Childrens.Add(frmCreateDialog.NewMenuSelection); TreeNode newTheme = new TreeNode(); newTheme.Name = frmCreateDialog.NewMenuSelection.Menu; newTheme.Text = frmCreateDialog.NewMenuSelection.PresText; newTheme.Tag = frmCreateDialog.NewMenuSelection; tvMenuSelection.SelectedNode.Nodes.Add(newTheme); tvMenuSelection.SelectedNode = newTheme; } } }