判断选中节点的文本不为空(如果有展示用户名)
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();
}
当用户点击节点时,可以获得他的selectedNode
this.TreeView1.SelectedNode.Name.toString();你在节点上把Name改名字就知道是哪个了。
tree.nodes.selectcount > 0
checked属性