本文整理汇总了C#中System.Web.UI.WebControls.TreeView.CollapseAll方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.CollapseAll方法的具体用法?C# TreeView.CollapseAll怎么用?C# TreeView.CollapseAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.TreeView
的用法示例。
在下文中一共展示了TreeView.CollapseAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create_TreeView_From_Collections
private void Create_TreeView_From_Collections(TreeView treeView1)
{
// Save the current home type
TreeNode rootNode = new TreeNode("Collection Hierarchy") {SelectAction = TreeNodeSelectAction.None};
treeView1.Nodes.Add(rootNode);
// Step through each node under this
SortedList<string, TreeNode> sorted_node_list = new SortedList<string, TreeNode>();
foreach (Item_Aggregation_Related_Aggregations childAggr in Hierarchy_Object.Children)
{
if ((!childAggr.Hidden) && ( childAggr.Active ))
{
// Set the aggregation value, for the redirect URL
currentMode.Aggregation = childAggr.Code.ToLower();
// Set some default interfaces
if (currentMode.Aggregation == "dloc1")
currentMode.Skin = "dloc";
if (currentMode.Aggregation == "edlg")
currentMode.Skin = "edl";
// Create this tree node
TreeNode childNode = new TreeNode("<a href=\"" + currentMode.Redirect_URL() + "\"><abbr title=\"" + childAggr.Description + "\">" + childAggr.Name + "</abbr></a>");
if (currentMode.Internal_User)
{
childNode.Text = string.Format("<a href=\"{0}\"><abbr title=\"{1}\">{2} ( {3} )</abbr></a>", currentMode.Redirect_URL(), childAggr.Description, childAggr.Name, childAggr.Code);
}
childNode.SelectAction = TreeNodeSelectAction.None;
childNode.NavigateUrl = currentMode.Redirect_URL();
// Add to the sorted list
if ((childAggr.Name.Length > 4) && (childAggr.Name.IndexOf("The ") == 0 ))
sorted_node_list.Add(childAggr.Name.Substring(4).ToUpper(), childNode);
else
sorted_node_list.Add(childAggr.Name.ToUpper(), childNode);
// Check the children nodes recursively
add_children_to_tree(childAggr, childNode);
currentMode.Skin = String.Empty;
}
}
// Now add the sorted nodes to the tree
foreach( TreeNode childNode in sorted_node_list.Values )
{
rootNode.ChildNodes.Add(childNode);
}
currentMode.Aggregation = String.Empty;
if ((currentMode.Home_Type == Home_Type_Enum.Tree_Expanded) || ( currentMode.Is_Robot ))
{
treeView1.ExpandAll();
}
else
{
treeView1.CollapseAll();
rootNode.Expand();
}
}
示例2: UpdateFileSystemTree
private void UpdateFileSystemTree(TreeView control, bool singleRoot, string rootName)
{
string path = RootDir;
if (Directory.Exists(path))
{
control.Nodes.Clear();
TreeNodeCollection rootNodes;
if (singleRoot)
{
if (Cache[path + rootName] != null)
{
rootNodes = (TreeNodeCollection)Cache[path + rootName];
}
else
{
rootNodes = GetFileSystemTree(path);
Cache.Insert(path + rootName, rootNodes, null, DateTime.MaxValue, TimeSpan.FromMinutes(10));
}
TreeNode root = new TreeNode(rootName);
foreach (TreeNode tn in rootNodes)
{
root.ChildNodes.Add(tn);
}
control.Nodes.Add(root);
}
else
{
if (Cache[path] != null)
{
rootNodes = (TreeNodeCollection)Cache[path];
}
else
{
rootNodes = GetFileSystemTree(path);
Cache.Insert(path, rootNodes, null, DateTime.MaxValue, TimeSpan.FromMinutes(10));
}
foreach (TreeNode tn in rootNodes)
{
control.Nodes.Add(tn);
}
}
control.CollapseAll();
}
else
{
FileManagerFooterBlock.InnerText = "Путь " + RequestedPath + " не существует";
}
}
示例3: pageLoadNodeExpandAll
public static void pageLoadNodeExpandAll (Page page) {
TreeView tv = new TreeView ();
tv.EnableClientScript = false;
tv.ID = "treeview1";
XmlDataSource xmlds = new XmlDataSource ();
xmlds.EnableCaching = false;
xmlds.Data = xmlDataBind;
tv.DataSource = xmlds;
tv.DataBind ();
tv.CollapseAll ();
tv.Nodes[0].ChildNodes[0].ExpandAll ();
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
page.Form.Controls.Add (lcb);
page.Form.Controls.Add (tv);
page.Form.Controls.Add (lce);
}
示例4: Add_Main_Viewer_Section
//.........这里部分代码省略.........
builder.AppendLine("</h2>");
// Add physical extent, if it exists
if (container.Extent.Length > 0)
builder.AppendLine("<strong>" + container.Extent + "</strong><br />");
// Add the scope content next
if (container.Scope_And_Content.Length > 0)
builder.AppendLine(container.Scope_And_Content);
// Add any bioghist next
if (container.Biographical_History.Length > 0)
builder.AppendLine(container.Biographical_History);
// Are there children to this top container
if (container.Children.Count > 0)
{
// Dump the current builder into a literal
Literal newLiteral = new Literal
{ Text = Text_Search_Term_Highlighter.Hightlight_Term_In_HTML( builder.ToString(), terms) };
MainPlaceHolder.Controls.Add(newLiteral);
// Clear the contents of the builder
builder.Remove(0, builder.Length);
// Now, add this as a tree
TreeView treeView1 = new TreeView
{ Width = new Unit(700), NodeWrap = true, EnableClientScript = true, PopulateNodesFromClient = false };
// Set some tree view properties
treeView1.TreeNodePopulate += treeView1_TreeNodePopulate;
// Add each child tree node
foreach (Container_Info child in container.Children)
{
// Add this node
TreeNode childNode = new TreeNode(child.Unit_Title) {SelectAction = TreeNodeSelectAction.None};
if (child.DAO_Link.Length > 0)
{
if (child.DAO_Title.Length > 0)
{
childNode.Text = child.Unit_Title + " <a href=\"" + child.DAO_Link + "\">" + child.DAO_Title + "</a>";
}
else
{
childNode.Text = "<a href=\"" + child.DAO_Link + "\">" + child.Unit_Title + "</a>";
}
}
treeView1.Nodes.Add(childNode);
// Add the description, if there is one
if (child.Scope_And_Content.Length > 0)
{
TreeNode scopeContentNode = new TreeNode(child.Scope_And_Content)
{SelectAction = TreeNodeSelectAction.None};
childNode.ChildNodes.Add(scopeContentNode);
}
// Add the grand children
if (child.Children_Count > 0)
{
foreach (Container_Info grandChild in child.Children)
{
// Add this node
TreeNode grandChildNode = new TreeNode(grandChild.Unit_Title)
{SelectAction = TreeNodeSelectAction.None};
if (grandChild.DAO_Link.Length > 0)
{
if (grandChild.DAO_Title.Length > 0)
{
grandChildNode.Text = grandChild.Unit_Title + " <a href=\"" + grandChild.DAO_Link + "\">" + grandChild.DAO_Title + "</a>";
}
else
{
grandChildNode.Text = "<a href=\"" + grandChild.DAO_Link + "\">" + grandChild.Unit_Title + "</a>";
}
}
childNode.ChildNodes.Add(grandChildNode);
}
}
}
// Configure the tree view collapsed nodes
treeView1.CollapseAll();
// Add this tree view to the place holder
MainPlaceHolder.Controls.Add(treeView1);
}
// Put some spaces for now
builder.AppendLine("<br /><br />");
}
builder.AppendLine(" </div>");
builder.AppendLine(" </td>");
// Add the HTML for the image
Literal mainLiteral = new Literal {Text = builder.ToString()};
MainPlaceHolder.Controls.Add(mainLiteral);
}
示例5: Add_Controls
//.........这里部分代码省略.........
if (thisFolder.IsPublic)
{
folderNode.ImageUrl = Static_Resources_Gateway.Open_Folder_Public_Jpg;
folderNode.ImageToolTip = "Public folder";
}
else
{
folderNode.ImageUrl = Static_Resources_Gateway.Open_Folder_Jpg;
}
folderNode.Text = " <span class=\"Selected_TreeNode_Text\">" + thisFolder.Folder_Name + "</span>";
folderNode.SelectAction = TreeNodeSelectAction.None;
}
else
{
if (thisFolder.IsPublic)
{
folderNode.ImageUrl = Static_Resources_Gateway.Closed_Folder_Public_Jpg;
folderNode.ImageToolTip = "Public folder";
}
else
{
folderNode.ImageUrl = Static_Resources_Gateway.Closed_Folder_Jpg;
}
folderNode.Text = " <a href=\"" + redirect_url.Replace("XXXXXXXXXXXXXXXXXX", thisFolder.Folder_Name_Encoded) + "\">" + thisFolder.Folder_Name + "</a>";
}
rootNode.ChildNodes.Add(folderNode);
// Add all the children nodes as well
add_children_nodes(folderNode, thisFolder, properFolderName, redirect_url, selectedNodes);
}
}
// Collapse the treeview
treeView1.CollapseAll();
if (selectedNodes.Count > 0)
{
TreeNode selectedNodeExpander = selectedNodes[0];
while (selectedNodeExpander.Parent != null)
{
(selectedNodeExpander.Parent).Expand();
selectedNodeExpander = selectedNodeExpander.Parent;
}
}
else
{
rootNode.Expand();
}
MainPlaceHolder.Controls.Add(treeView1);
}
if (RequestSpecificValues.Current_Mode.My_Sobek_SubMode.Length > 0)
{
if ( RequestSpecificValues.Results_Statistics.Total_Titles == 0)
{
Literal literal = new Literal();
string folder_name = RequestSpecificValues.Current_User.Folder_Name(RequestSpecificValues.Current_Mode.My_Sobek_SubMode);
RequestSpecificValues.Current_Mode.My_Sobek_SubMode = String.Empty;
if (folder_name.Length == 0)
{
UrlWriterHelper.Redirect(RequestSpecificValues.Current_Mode);
return;
}
if (properFolderName != "Submitted Items")
示例6: CreateChildControls
protected override void CreateChildControls()
{
menuTree = new TreeView();
menuTree.SelectedNodeStyle.Font.Bold = true;
foreach (HierarchyRow r in (hierarchyDataset.Tables[0]).Rows)
{
if (r.ParentId == null)
{
TreeNode item = new TreeNode(r.Caption, r.Id.ToString());
menuTree.Nodes.Add(item);
AddSubtreeForItem(r, item);
}
}
//inList.EnableViewState = true;
//outList.EnableViewState = true;
panelList.DataSource = panelsTable;
panelList.DataValueField = "Id";
panelList.DataTextField = "Name";
panelList.DataBind();
panelList.ID = "panelList";
removeButton.Text = "Remove selected";
renameButton.Text = "Rename selected";
addButton.Text = "AddNode";
bindButton.Text = "Bind To Panel";
unbindButton.Text = "Unbind Panel";
menuTree.SelectedNodeChanged += OnSelectedNodeChanged;
bindButton.Click += OnBindButtonClicked;
unbindButton.Click += OnUnbindButtonClicked;
addButton.Click += OnAddButtonClicked;
removeButton.Click += OnRemoveButtonClicked;
renameButton.Click += OnRenameButtonClicked;
panelList.Height = 500;
menuTree.ShowLines = true;
menuTree.CollapseAll();
this.Controls.Clear();
this.Controls.Add(menuTree);
this.Controls.Add(panelList);
this.Controls.Add(bindButton);
this.Controls.Add(unbindButton);
this.Controls.Add(newLabelTB);
this.Controls.Add(addButton);
this.Controls.Add(removeButton);
this.Controls.Add(renameButton);
}
示例7: remplirTreeview
//========================================================= remplirTreeview() ============================================================
private void remplirTreeview(TreeView tree, SPList list, string libelle)
{
treeViewList = new List<TreeViewItem>();
SPQuery myquery = new SPQuery();
myquery.Query = "";
SPListItemCollection items = list.GetItems(myquery);
foreach (SPListItem item in items)
{
treeViewList.Add(new TreeViewItem()
{
ParentID = item["Service Parent"].ToString(),
ID = item[libelle].ToString(),
Text = item[libelle].ToString()
});
}
PopulateTreeView("CASA", null);
tree.CollapseAll();
}