private void btnFindCommand_Click(object sender, EventArgs e) { InputNameDialog dlg = new InputNameDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } string name = dlg.InputText; foreach (TreeNode root in treeView1.Nodes) { foreach (TreeNode node in root.Nodes) { if (string.Compare(node.Text, name, StringComparison.OrdinalIgnoreCase) == 0) { treeView1.SelectedNode = node; node.EnsureVisible(); return; } } } MessageBox.Show("指定的命令名称不存在。", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information); }
public static string GetInputString() { InputNameDialog dlg = new InputNameDialog(); if (dlg.ShowDialog() == DialogResult.OK) { return(dlg.InputText); } else { return(null); } }
private void btnAddFile_Click(object sender, EventArgs e) { InputNameDialog dlg = new InputNameDialog(); if (dlg.ShowDialog() != DialogResult.OK) { return; } TreeNode node = new TreeNode(dlg.InputText, Icon_ConfigFile, Icon_ConfigFile2); treeView1.Nodes.Add(node); treeView1.SelectedNode = node; node.EnsureVisible(); SetChangedAndRefreshUIAndTreeFocus(); }