如何通过text来选中TreeView 子节点

2024-12-17 13:31:55
推荐回答(2个)
回答1:

private void treeFriend_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e)
{

if (treeFriend.SelectedNode.Text != "我的好友")
{
Thread thread = new Thread(new ParameterizedThreadStart(friendShow));
thread.IsBackground = true;
thread.SetApartmentState( ApartmentState.STA);
thread.Start(treeFriend.SelectedNode.Text);

}

}

private void friendShow(object o)
{
string str = (string)o;
Chat mychat = new Chat();
mychat.Text = str;
mychat.ShowDialog();
}

回答2:

遍历每一个子节点,判断子节点显示的文字是不是你要寻找的,是的话,选中它,KO