本文整理汇总了C#中System.Windows.Forms.TreeNodeCollection.MoveNext方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.MoveNext方法的具体用法?C# TreeNodeCollection.MoveNext怎么用?C# TreeNodeCollection.MoveNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.MoveNext方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnsureVisible
public void EnsureVisible()
{
if( null == treeView ) return;
TreeView.NodeEnumerator nodes;
int nodeFromTop;
int nodeNo;
while (true)
{
// Find "this" node number and position from the top control.
nodeFromTop = -1;
nodeNo = 0;
bool nodeFound = false;
nodes = new TreeView.NodeEnumerator(treeView.nodes);
while (nodes.MoveNext())
{
if (nodes.currentNode == treeView.topNode)
{
// We are at the top of the control.
nodeFromTop = 0;
}
if (nodes.currentNode == this)
{
if (nodeFromTop < 0)
{
treeView.topNode = this;
treeView.Invalidate();
return;
}
nodeFound = true;
break;
}
if (nodeFromTop >= 0)
{
nodeFromTop++;
}
nodeNo++;
}
if (nodeFound)
{
break;
}
else
{
// Make sure all parents are expanded and see if its now visible.
TreeNode node = this;
TreeNode highestNode = node;
for (; node != null; node = node.Parent)
{
node.expanded = true;
highestNode = node;
}
treeView.InvalidateDown(highestNode);
}
}
int visibleNodes = treeView.VisibleCountActual;
// See if its already visible.
if (nodeFromTop < visibleNodes)
{
return;
}
// Set the top node no we want to make this node 1 up from the bottom.
nodeFromTop = nodeNo - visibleNodes + 1;
if (nodeFromTop < 0)
{
nodeFromTop = 0;
}
// Find the node corresponding to this node no.
nodes.Reset();
nodeNo = 0;
while (nodes.MoveNext())
{
if (nodeFromTop == nodeNo)
{
treeView.topNode = nodes.currentNode;
treeView.Invalidate();
break;
}
nodeNo++;
}
}