本文整理汇总了C#中System.Windows.Forms.TreeNode.SortChildren方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.SortChildren方法的具体用法?C# TreeNode.SortChildren怎么用?C# TreeNode.SortChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNode
的用法示例。
在下文中一共展示了TreeNode.SortChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddSorted
internal int AddSorted(TreeNode node)
{
int pos = 0;
string text = node.Text;
if (childCount > 0)
{
Globalization.CompareInfo compare = Application.CurrentCulture.CompareInfo;
// Simple optimization if added in sort order
if (compare.Compare(children[(childCount - 1)].Text, text) <= 0)
pos = childCount;
else
{
// Binary Search
int i = 0;
int j = childCount;
while (i < j)
{
int mid = (i + j) / 2;
if (compare.Compare(children[mid].Text, text) <= 0)
i = mid + 1;
else
i = mid;
}
pos = i;
}
}
node.SortChildren();
InsertNodeAt(pos, node);
if (treeView != null && node == treeView.selectedNode)
{
treeView.SelectedNode = node;
}
return pos;
}
示例2: AddSorted
internal int AddSorted(TreeNode node)
{
int index = 0;
string text = node.Text;
System.Windows.Forms.TreeView treeView = this.TreeView;
if (this.childCount > 0)
{
int num2;
int childCount;
int num4;
if (treeView.TreeViewNodeSorter == null)
{
CompareInfo compareInfo = Application.CurrentCulture.CompareInfo;
if (compareInfo.Compare(this.children[this.childCount - 1].Text, text) <= 0)
{
index = this.childCount;
}
else
{
num2 = 0;
childCount = this.childCount;
while (num2 < childCount)
{
num4 = (num2 + childCount) / 2;
if (compareInfo.Compare(this.children[num4].Text, text) <= 0)
{
num2 = num4 + 1;
}
else
{
childCount = num4;
}
}
index = num2;
}
}
else
{
IComparer treeViewNodeSorter = treeView.TreeViewNodeSorter;
num2 = 0;
childCount = this.childCount;
while (num2 < childCount)
{
num4 = (num2 + childCount) / 2;
if (treeViewNodeSorter.Compare(this.children[num4], node) <= 0)
{
num2 = num4 + 1;
}
else
{
childCount = num4;
}
}
index = num2;
}
}
node.SortChildren(treeView);
this.InsertNodeAt(index, node);
return index;
}
示例3: AddSorted
/// <include file='doc\TreeNode.uex' path='docs/doc[@for="TreeNode.AddSorted"]/*' />
/// <devdoc>
/// Adds a new child node at the appropriate sorted position
/// </devdoc>
/// <internalonly/>
internal int AddSorted(TreeNode node) {
int index = 0;
int iMin, iLim, iT;
string nodeText = node.Text;
TreeView parentTreeView = TreeView;
if (childCount > 0) {
if (parentTreeView.TreeViewNodeSorter == null)
{
CompareInfo compare = Application.CurrentCulture.CompareInfo;
// Optimize for the case where they're already sorted
if (compare.Compare(children[childCount-1].Text, nodeText) <= 0)
index = childCount;
else {
// Insert at appropriate sorted spot
for (iMin = 0, iLim = childCount; iMin < iLim;) {
iT = (iMin + iLim) / 2;
if (compare.Compare(children[iT].Text, nodeText) <= 0)
iMin = iT + 1;
else
iLim = iT;
}
index = iMin;
}
}
else
{
IComparer sorter = parentTreeView.TreeViewNodeSorter;
// Insert at appropriate sorted spot
for (iMin = 0, iLim = childCount; iMin < iLim;) {
iT = (iMin + iLim) / 2;
if (sorter.Compare(children[iT] /*previous*/, node/*current*/) <= 0)
iMin = iT + 1;
else
iLim = iT;
}
index = iMin;
}
}
node.SortChildren(parentTreeView);
InsertNodeAt(index, node);
return index;
}