本文整理汇总了C#中System.Web.UI.WebControls.TreeView.FindNode方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.FindNode方法的具体用法?C# TreeView.FindNode怎么用?C# TreeView.FindNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.TreeView
的用法示例。
在下文中一共展示了TreeView.FindNode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExpandValuePath
private static void ExpandValuePath(TreeView treeView, string valuePath)
{
if (treeView == null) return;
if (valuePath == null) return;
if (valuePath.Length > 0)
{
TreeNode treeNode;
treeNode = treeView.FindNode(valuePath);
if (treeNode != null)
{
if (
(treeNode.Expanded == null)
|| (treeNode.Expanded.Equals(false))
)
{
treeNode.Expand();
log.Debug("Expanded treeNode found for value path " + valuePath);
}
}
else
{
log.Debug(" treeNode was null for " + valuePath);
}
}
}
示例2: InsertNode
/* value should be empty for classname nodes, namespace name for namespace nodes */
private void InsertNode(TreeView tv, string text, string value, string valuepath, TreeNodeCollection parent)
{
TreeNode node = tv.FindNode(valuepath);
if (node == null)
{
node = new TreeNode(Server.HtmlEncode(text), value);
if (parent == null)
{
tv.Nodes.Add(node);
}
else
{
parent.Add(node);
}
if (valuepath == query_ns)
{
node.Selected = true;
}
else if (!query_ns.StartsWith(valuepath))
{
node.Collapse();
}
}
}
示例3: GenarateMainMenu
protected void GenarateMainMenu()
{
#region 生成主菜单datatable
DataTable dt = Right_Module_BLL.GetBrowseMoudleByUser(Session["UserName"].ToString());
DataRow[] RootRows = dt.Select("SuperID=1");
if (dt != null && RootRows.Length > 0)
{
for (int i = 0; i < RootRows.Length; i++)
{
DataRow dr = RootRows[i];
int superid = (int)dr["SuperID"];
int menuid = (int)dr["ID"];
if (superid == 1)
{
AjaxControlToolkit.AccordionPane p = new AjaxControlToolkit.AccordionPane();
p.ID = "AccordionPane" + menuid.ToString();
HyperLink hy = new HyperLink();
hy.Text = (string)dr["Name"];
p.HeaderContainer.Controls.Add(hy);
TreeView tr = new TreeView();
tr.ImageSet = TreeViewImageSet.Custom;
tr.ShowExpandCollapse = true;
tr.ExpandImageUrl = "~/Images/icon/TreeExpand.gif";
tr.NoExpandImageUrl = "~/Images/icon/TreeNode.gif";
tr.CollapseImageUrl = "~/Images/icon/TreeCollapse.gif";
tr.SelectedNodeStyle.Font.Bold = true;
tr.SelectedNodeStyle.ForeColor = System.Drawing.Color.Red;
tr.SelectedNodeStyle.BackColor = System.Drawing.Color.Yellow;
tr.EnableViewState = true;
GenareateSubMenu(dt, i, tr.Nodes, menuid);
tr.SelectedNodeChanged += tr_SelectedNodeChanged;
tr.TreeNodePopulate += tr_TreeNodePopulate;
p.ContentContainer.Controls.Add(tr);
Ac_MainMenu.Panes.Add(p);
#region 只有当前已选择的树节点及至所有父节点才展开,其余折叠
if (Session["ActiveRootNode"] != null && (int)Session["ActiveRootNode"] == i && ViewState["CurrentRootNode"] != null)
{
string nodepath = (string)ViewState["CurrentRootNode"];
TreeNode node = tr.FindNode(nodepath);
if (node != null)
{
//node.ImageUrl = "~/Images/icon/TreeCollapse.gif";
node.ExpandAll();
}
}
#endregion
}
}
if (Session["ActiveRootNode"] != null) Ac_MainMenu.SelectedIndex = (int)Session["ActiveRootNode"];
//wc.DataSource = dt;
}
else
Response.Write("对不起,当前用户没有分配任何浏览权限!");
#endregion
}