private void tSMItem_BusMedel_Add_Click(object sender, EventArgs e) { TreeNode _treenode = treeView_ProductInfo.SelectedNode; if (_treenode != null) { string name = DateTime.Now.TimeOfDay.ToString(); treeView_ProductInfo.SelectedNode.Nodes.Add(name, name); productContrainer.AddSubProduct(name); } }
/// <summary> /// Left——》Middle /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tSMItem_BusMedel_Add_Click(object sender, EventArgs e) { TreeNode _treenode = treeView_ProductInfo.SelectedNode; if (_treenode != null) { List <string> NameList = new List <string>(); foreach (TreeNode it in _treenode.Nodes) { NameList.Add(it.Text); } var ExistNode = NameList.Where(n => n.Contains((sender as ToolStripMenuItem).Text)); var Name = $"{(sender as ToolStripMenuItem).Text}_{ExistNode.Count() + 1}"; treeView_ProductInfo.SelectedNode.Nodes.Add(Name, Name); productContrainer.AddSubProduct((sender as ToolStripMenuItem).Text, ExistNode.Count() + 1, NameList.Count() + 1); } }