public MainForm() { InitializeComponent(); Node = new NewTreeNode("Корень "); treeView.Nodes.Add(Node); listBox.MultiColumn = true; }
/// <summary> /// Adding a section. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void addMenuItem_Click(object sender, EventArgs e) { try { NewTreeNode node = new NewTreeNode(); node.Text = "Новый раздел"; treeView.SelectedNode.Nodes.Add(node); treeView.SelectedNode = node; treeView.SelectedNode.BeginEdit(); } catch { MessageBox.Show("Что-то пошло не так..."); } }
/// <summary> /// Csv writer. /// </summary> /// <param name="treeNode"></param> void csvWriter(NewTreeNode treeNode) { if (treeNode.Nodes.Count > 0) { foreach (NewTreeNode node in treeNode.Nodes) { csvWriter(node); } } else { foreach (var item in treeNode.Items) { try { csv.Append($"\n{treeNode.FullPath};{item.Name};{item.VendorCode};{item.Price};{item.Count}"); } catch { } } } }