select a treenode, and expand all parent nodes of it.
private void SetSelectedNode(int sira)
{
if (sira > 0)
{
TreeNode selectedNode = null;
foreach (TreeNode node in tvMadde.Nodes)
{
if (node.Value == sira.ToString())
{
selectedNode = node;
}
if (selectedNode == null)
{
if (node.ChildNodes.Count > 0)
{
selectedNode = GetNode(node, sira);
}
}
else
{
selectedNode.Checked = true;
selectedNode.Select();
if (selectedNode.Parent != null)
{
// selectedNode.Parent.Expand();
// selectednode'un tüm parent'larını aç
ExpandParent(selectedNode);
}
break;
//return;
}
}
if (selectedNode != null)
{
selectedNode.Checked = true;
selectedNode.Select();
selectedNode.Parent.Expand();
}
}
}
private void ExpandParent(TreeNode childNode)
{
if (childNode.Parent != null)
{
childNode.Parent.Expand();
ExpandParent(childNode.Parent);
}
}
select a treenode, and expand all parent nodes of it
Gönderen
pantepember
19 Ağustos 2010 Perşembe