本文整理汇总了C#中System.Web.UI.WebControls.TreeNode.ExpandAll方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.ExpandAll方法的具体用法?C# TreeNode.ExpandAll怎么用?C# TreeNode.ExpandAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.TreeNode
的用法示例。
在下文中一共展示了TreeNode.ExpandAll方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompletaAlbero
private void CompletaAlbero(TreeNodeCollection nodes, Business.Entity.Guida guida)
{
var voce = Business.Entity.Guida.GetItem(Business.Entity.Guida.KeyColumnsEnum.Id, guida.Id);
TreeNode node = new TreeNode(voce.Titolo, voce.Id.ToString());
if (NodiEspansi.Contains(voce.Id)) node.ExpandAll();
foreach (var item in GuidaCollection.GetList(wherePredicate: "IdPrec == @0", whereValues: new object[] { voce.Id }, orderPredicate: "Posizione ASC")) CompletaAlbero(node.ChildNodes, item);
nodes.Add(node);
}
示例2: GetChildNode
private TreeNodeCollection GetChildNode(string RootNode, string[] valueArray, List<SPListItem> objListItemColn)
{
TreeNodeCollection childtreenodes = new TreeNodeCollection();
SPQuery objSPQuery;
SPListItemCollection objItems = null;
List<SPListItem> objNodeListItems = new List<SPListItem>();
SiteMapNodeCollection objNode = new SiteMapNodeCollection();
objSPQuery = new SPQuery();
string objNodeTitle = string.Empty;
string objLookupColumn = string.Empty;
StringBuilder Query = new StringBuilder();
SPList objTaskList;
SPField spField;
string objKeyColumn;
try
{
objTaskList = SPContext.Current.Web.Lists[objTreeViewControlField.ListName];
objLookupColumn = objTreeViewControlField.ParentLookup;
spField = SPContext.Current.Web.Lists[objTreeViewControlField.ListName].Fields[objTreeViewControlField.ParentLookup];
if (this.ControlMode == SPControlMode.Display)
{
objNodeListItems = (from SPListItem Item in objListItemColn
where (new SPFieldLookupValue(Convert.ToString(Item[objTreeViewControlField.ParentLookup])).LookupValue == RootNode)
orderby Item.ID
select Item).ToList();
}
else
{
Query.Append(String.Format(GlobalConstants.DYNAMIC_CAML_QUERY_GET_CHILD_NODE, spField.InternalName, RootNode));
objSPQuery.Query = Query.ToString();
objItems = objTaskList.GetItems(objSPQuery);
foreach (SPListItem objItem in objItems)
{
objNodeListItems.Add(objItem);
}
}
if (objNodeListItems != null && objNodeListItems.Count > 0)
{
foreach (SPListItem objItem in objNodeListItems)
{
RootNode = Convert.ToString(objItem[GlobalConstants.LIST_COLUMN_TITLE]);
objKeyColumn = Convert.ToString(objItem[objTreeViewControlField.KeyColumn]);
objNodeTitle = Convert.ToString(objItem[objTreeViewControlField.ValueColumn]);
if (!String.IsNullOrEmpty(objNodeTitle))
{
TreeNode childNode = new TreeNode();
childNode.Text = objNodeTitle;
childNode.Value = objKeyColumn;
childNode.ExpandAll();
if (valueArray != null && this.ControlMode == SPControlMode.Edit && valueArray.Contains(childNode.Value))
{
childNode.ShowCheckBox = true;
childNode.Checked = true;
}
else if (this.ControlMode == SPControlMode.Display)
{
childNode.ShowCheckBox = false;
}
else
{
childNode.ShowCheckBox = true;
}
foreach (TreeNode cnode in GetChildNode(RootNode, valueArray, objListItemColn))
{
childNode.ChildNodes.Add(cnode);
cnode.SelectAction = TreeNodeSelectAction.None;
if (valueArray != null && this.ControlMode == SPControlMode.Edit && valueArray.Contains(cnode.Value))
{
cnode.ShowCheckBox = true;
cnode.Checked = true;
}
else if (this.ControlMode == SPControlMode.Display)
{
cnode.ShowCheckBox = false;
}
else
{
cnode.ShowCheckBox = true;
}
}
childtreenodes.Add(childNode);
}
}
}
return childtreenodes;
}
catch (Exception ex)
{
throw new Exception(GlobalConstants.ERROR_MESSAGE_CHILDNODE_CREATION_FAILED + GlobalConstants.HTML_BR + ex.Message);
}
// Call method again (recursion) to get the child items
//.........这里部分代码省略.........
示例3: CompletaAlbero
private void CompletaAlbero(TreeNodeCollection nodes, Business.Entity.Categorie categorie)
{
var numProd = AnnunciCategorieCollection.GetCount("IdCategorie == " + categorie.Id);
//Prendo la categoria con la lingua di default
var cat = Business.Entity.Categorie.GetItem(Business.Entity.Categorie.KeyColumnsEnum.Id, categorie.Id);
TreeNode node = new TreeNode(cat.Nome + " (" + numProd + ")", cat.Id.ToString());
if (NodiEspansi.Contains(cat.Id)) node.ExpandAll();
foreach (var item in CategorieCollection.GetList(wherePredicate: "IdPrec == @0", whereValues: new object[] { categorie.Id }, orderPredicate: "Posizione ASC")) CompletaAlbero(node.ChildNodes, item);
nodes.Add(node);
}
示例4: GetChildNode
private TreeNodeCollection GetChildNode(string RootNode, string[] valueArray, List<SPListItem> objListItemColn)
{
TreeNodeCollection childtreenodes = new TreeNodeCollection();
SPQuery objSPQuery;
SPListItemCollection objItems = null;
List<SPListItem> objNodeListItems = new List<SPListItem>();
SiteMapNodeCollection objNode = new SiteMapNodeCollection();
objSPQuery = new SPQuery();
string objNodeTitle = string.Empty;
string objLookupColumn = string.Empty;
StringBuilder Query = new StringBuilder();
SPList objTaskList;
SPField spField;
objTaskList = SPContext.Current.Web.Lists[objTreeViewControlField.ListName];
objLookupColumn = objTreeViewControlField.ParentLookup;
spField = SPContext.Current.Web.Lists[objTreeViewControlField.ListName].Fields[objTreeViewControlField.ParentLookup];
if (this.ControlMode == SPControlMode.Display)
{
objNodeListItems = (from SPListItem Item in objListItemColn
where (new SPFieldLookupValue(Convert.ToString(Item[objTreeViewControlField.ParentLookup])).LookupValue == RootNode)
orderby Item.ID
select Item).ToList();
}
else
{
Query.Append(String.Format("<Where><Eq><FieldRef Name='" + spField.InternalName + "' /><Value Type='LookupMulti'>{0}</Value></Eq></Where>", RootNode));
objSPQuery.Query = Query.ToString();
objItems = objTaskList.GetItems(objSPQuery);
foreach (SPListItem objItem in objItems)
{
objNodeListItems.Add(objItem);
}
}
if (objNodeListItems != null && objNodeListItems.Count > 0)
{
foreach (SPListItem objItem in objNodeListItems)
{
RootNode = Convert.ToString(objItem[GlobalConstants.LIST_COLUMN_TITLE]);
objNodeTitle = Convert.ToString(objItem[objTreeViewControlField.ValueColumn]);
if (!String.IsNullOrEmpty(objNodeTitle))
{
TreeNode childNode = new TreeNode();
childNode.Text = objNodeTitle;
childNode.Value = RootNode;
childNode.ExpandAll();
if (valueArray != null && this.ControlMode == SPControlMode.Edit && valueArray.Contains(childNode.Value))
{
childNode.ShowCheckBox = true;
childNode.Checked = true;
}
else if (this.ControlMode == SPControlMode.Display)
{
childNode.ShowCheckBox = false;
}
else
{
childNode.ShowCheckBox = true;
}
foreach (TreeNode cnode in GetChildNode(RootNode, valueArray, objListItemColn))
{
childNode.ChildNodes.Add(cnode);
cnode.SelectAction = TreeNodeSelectAction.None;
if (valueArray != null && this.ControlMode == SPControlMode.Edit && valueArray.Contains(cnode.Value))
{
cnode.ShowCheckBox = true;
cnode.Checked = true;
}
else if (this.ControlMode == SPControlMode.Display)
{
cnode.ShowCheckBox = false;
}
else
{
cnode.ShowCheckBox = true;
}
}
childtreenodes.Add(childNode);
}
}
}
return childtreenodes;
// Call method again (recursion) to get the child items
//.........这里部分代码省略.........