/// <summary>
/// 设置TreeView选中节点
/// </summary>
/// <param name="treeView"></param>
/// <param name="selectStr">选中节点文本</param>
private void SelectTreeView(TreeView treeView, string selectStr)
{
treeView.Focus();
for (int i = 0; i < treeView.Nodes.Count; i++)
{
for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++)
{
if (treeView.Nodes[i].Nodes[j].Text == selectStr)
{
treeView1.SelectedNode = treeView.Nodes[i].Nodes[j];//选中
//treeView.Nodes[i].Nodes[j].Checked = true;
treeView.Nodes[i].Expand();//展开父级
return;
}
}
}
}
本文作者:greatverve 来源:网络
CIO之家 www.ciozj.com 微信公众号:imciow