本文整理汇总了C#中System.Web.UI.WebControls.TreeNodeCollection.Cast方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.Cast方法的具体用法?C# TreeNodeCollection.Cast怎么用?C# TreeNodeCollection.Cast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.Cast方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsChildNodeSelected
/// <summary>
/// Determines whether [is child node selected] [the specified nodes].
/// </summary>
/// <param name="nodes">
/// The nodes.
/// </param>
/// <returns>
/// <c>true</c> if [is child node selected] [the specified nodes]; otherwise, <c>false</c>.
/// </returns>
/// <remarks>
/// </remarks>
private bool IsChildNodeSelected(TreeNodeCollection nodes)
{
var bRet = false;
if (nodes != null)
{
bRet = nodes.Cast<TreeNode>().Any(node => node.Selected || this.IsChildNodeSelected(node.ChildNodes));
}
return bRet;
}
示例2: ExpandToDepth
/// <summary>
/// The expand to depth.
/// </summary>
/// <param name="nodes">
/// The nodes.
/// </param>
/// <param name="expandDepth">
/// The expand depth.
/// </param>
public static void ExpandToDepth(TreeNodeCollection nodes, int expandDepth)
{
if (nodes == null)
{
return;
}
foreach (var node in nodes.Cast<TreeNode>().Where(node => node.Depth < expandDepth))
{
node.Expand();
ExpandToDepth(node.ChildNodes, expandDepth);
}
}
示例3: ComposeViewState
/// <summary>
/// Composes the state of the view.
/// </summary>
/// <param name="nodes">
/// The nodes.
/// </param>
/// <param name="state">
/// The state.
/// </param>
/// <returns>
/// The compose view state.
/// </returns>
/// <remarks>
/// </remarks>
private string ComposeViewState(TreeNodeCollection nodes, string state)
{
if (nodes != null)
{
foreach (var node in nodes.Cast<TreeNode>().Where(IsExpandable))
{
if (node.Expanded.Equals(true))
{
state += "e";
state = this.ComposeViewState(node.ChildNodes, state);
}
else
{
state += "n";
}
}
}
return state;
}
示例4: CheckNode
//初始化要选中的项
private void CheckNode(TreeNodeCollection nodes, IList<string> valuelist, ref int depth)
{
foreach (var node in nodes.Cast<TreeNode>())
{
if (valuelist.Contains(node.Value))
{
node.Checked = true;
depth = Math.Max(depth, node.Depth);
}
if (node.ChildNodes.Count > 0)
{
CheckNode(node.ChildNodes, valuelist, ref depth);
}
}
}