private void displayTree_EditCancelled(object sender, TreeNodeAdvEditEventArgs e) { e.Node.Text = oldGroupName; }
private void displayTree_NodeEditorValidated(object sender, TreeNodeAdvEditEventArgs e) { if (e.Node is DisplayGroupNode) { string newGroupName = e.Label.Trim(); bool errors = false; if (newGroupName == String.Empty) { MessageBoxExt.Show("Название группы не должно быть пустым!", "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning); errors = true; } else { if (PresentationController.Instance.Presentation.DisplayGroupList.Except(new[] { ((DisplayGroupNode)e.Node).DisplayGroup }).Any(d => d.Name == newGroupName)) { MessageBoxExt.Show(String.Format("{0} уже существует. Введите другое название", newGroupName), "Внимание!", MessageBoxButtons.OK, MessageBoxIcon.Warning); errors = true; } } if (errors) { string tmp = oldGroupName; displayTree.EndEdit(true); displayTree.BeginEdit(e.Node); oldGroupName = tmp; } else { (e.Node as DisplayGroupNode).DisplayGroup.Name = newGroupName; } } }