默认选中TreeView某个节点的方法
/// <summary>
/// 选中treeview的某个节点,需要每个node的value不同
/// </summary>
/// <param name="sNodeValue"></param>
private void checkNode(TreeView tv,string sNodeValue)
{
foreach (TreeNode tRoot in tv.Nodes)
{
if (tRoot.Value == sNodeValue)
{
tRoot.Select();
}
else
{
if (tRoot.ChildNodes != null)
{
foreach (TreeNode tChild in tRoot.ChildNodes)
{
if (tChild.Value == sNodeValue)
tChild.Select();
}
}
}
}
}
/// 选中treeview的某个节点,需要每个node的value不同
/// </summary>
/// <param name="sNodeValue"></param>
private void checkNode(TreeView tv,string sNodeValue)
{
foreach (TreeNode tRoot in tv.Nodes)
{
if (tRoot.Value == sNodeValue)
{
tRoot.Select();
}
else
{
if (tRoot.ChildNodes != null)
{
foreach (TreeNode tChild in tRoot.ChildNodes)
{
if (tChild.Value == sNodeValue)
tChild.Select();
}
}
}
}
}