我有一個(gè)簡(jiǎn)單的代碼,用于創(chuàng)建帶有添加、刪除和編輯按鈕的樹(shù)結(jié)構(gòu)。我想通過(guò)文本框 (textBox1) 和按鈕按下 (button4) 從添加的節(jié)點(diǎn)中搜索特定節(jié)點(diǎn),但我似乎無(wú)法使其工作。有什么建議么?using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form{ public Form1() { InitializeComponent(); } private void Button1_Click(object sender, EventArgs e) { TreeNode node = new TreeNode(textBox1.Text); try { treeView1.SelectedNode.Nodes.Add(node); } catch (Exception) { treeView1.Nodes.Add(node); } } private void Button2_Click(object sender, EventArgs e) { treeView1.SelectedNode.Text = textBox1.Text; } private void TreeView1_AfterSelect(object sender, TreeViewEventArgs e) { textBox1.Text = treeView1.SelectedNode.Text; } private void Button3_Click(object sender, EventArgs e) { treeView1.SelectedNode.Remove(); } private void Button4_Click(object sender, EventArgs e) { }}}
如何通過(guò)按下按鈕時(shí)輸入的文本搜索此樹(shù)視圖中的特定節(jié)點(diǎn)?
蠱毒傳說(shuō)
2022-12-31 10:55:11