public void AddDirectory(TreeNodeCollection nodes, CmsDirectory dir) { TreeNode node = new TreeNode(); node.NavigateUrl = dir.FileType.BrowseUrl + "?FileID=" + dir.ID; node.Text = dir.Title; node.Value = dir.FileID.ToString(); if (CurrentFile != null && CurrentFile.IsDescendantOf(dir)) { node.ImageUrl = dir.FileType.Module.ResourceFolder + "/images/icon_" + dir.FileType.CssClass + "_open.png"; if (CurrentFile.ID == dir.ID || CurrentFile.ParentID == dir.ID) { node.Selected = true; } } else { node.Expanded = false; node.ImageUrl = dir.FileType.Module.ResourceFolder + "/images/icon_" + dir.FileType.CssClass + ".png"; } nodes.Add(node); if (dir.Subdirectories.Count > 0) { if (CurrentFile != null && CurrentFile.IsDescendantOf(dir) && CurrentFile.FileID != dir.FileID) { node.Expanded = true; foreach (CmsDirectory sub in dir.Subdirectories) { if (sub.State != CmsState.Deleted) { AddDirectory(node.ChildNodes, sub); } } } else { node.PopulateOnDemand = true; } } }
private void InitTreeNode(TreeNodeCollection Nds, string UpDir) { string AbsPath = this.AppPath + UpDir + "/"; AbsPath = AbsPath.Replace("/", @"\"); AbsPath = AbsPath.Replace(@"\\", @"\"); TreeNode tmpNd; string search = "UploadFile.aspx?Dir="; DataTable dt = FileSystemObject.GetDirectoryInfos(AbsPath, FsoMethod.Folder); foreach (DataRow dr in dt.Rows) { tmpNd = new TreeNode(); string objPath=UpDir+"/"+dr["Name"].ToString(); tmpNd.Value = dr["Name"].ToString(); tmpNd.Text = dr["Name"].ToString(); tmpNd.NavigateUrl = search + base.Server.UrlEncode(objPath); tmpNd.Target = "main_right"; Nds.Add(tmpNd); string NextDir=UpDir+"/"+tmpNd.Value; string aPath = this.AppPath + NextDir + "/"; aPath = aPath.Replace("/", @"\"); aPath = aPath.Replace(@"\\", @"\"); if (FileSystemObject.GetDirectoryInfos(aPath, FsoMethod.Folder).Rows.Count > 0) { InitTreeNode(tmpNd.ChildNodes, NextDir); } } }
//将Xml类型转化成treeview类型 private void XmlToTreeview(XmlNodeList xmlNodeList, System.Web.UI.WebControls.TreeNodeCollection treeNode) { int CurOrder = 0; string CurTime = DateTime.Now.ToLongTimeString(); foreach (XmlNode xmlNode in xmlNodeList) { if (xmlNode.NodeType != XmlNodeType.Element) { continue; } System.Web.UI.WebControls.TreeNode newTreeNode = new System.Web.UI.WebControls.TreeNode(); newTreeNode.Text = xmlNode.LocalName; newTreeNode.Value = CurTime + CurOrder.ToString(); CurOrder++; if (xmlNode.HasChildNodes) { if (xmlNode.ChildNodes[0].NodeType == XmlNodeType.Text) { newTreeNode.Text += " 【 " + xmlNode.ChildNodes[0].Value + "】"; //newTreeNode.Value = xmlNode.ChildNodes[0].Value; newTreeNode.Value = CurTime + CurOrder.ToString(); CurOrder++; } XmlToTreeview(xmlNode.ChildNodes, newTreeNode.ChildNodes); } treeNode.Add(newTreeNode); } }
private void TreeviewToXml(System.Web.UI.WebControls.TreeNodeCollection treeNodes, XmlNode xmlNode) { XmlDocument doc = xmlNode.OwnerDocument; foreach (System.Web.UI.WebControls.TreeNode treeNode in treeNodes) { string[] Array = treeNode.Text.Split(new char[2] { '【', '】' }); XmlNode element = doc.CreateNode("element", Array[0].Trim(), ""); try { element.InnerText = Array[1]; } catch (Exception) { element.InnerText = ""; } xmlNode.AppendChild(element); if (treeNode.ChildNodes.Count > 0) { TreeviewToXml(treeNode.ChildNodes, element); } } }
//Populate tree node public void TreeNodePopulate(TreeNodeCollection nodes, IToken token) { //Parents nodes treeNodes = authorManager.getAllPermission(); treeNodes.Merge(authorManager.getAuthoritiesByToken(token)); CreateRootNode(nodes); }
private void PopulateNodes2(TreeNodeCollection nodes, int parent) { ZhuJi.Portal.IDAL.IPlugin plugin = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Plugin)) as ZhuJi.Portal.IDAL.IPlugin; IList<ZhuJi.Portal.Domain.Plugin> list = plugin.GetObjects(); ZhuJi.Portal.Domain.PluginCollection plugins = new ZhuJi.Portal.Domain.PluginCollection(); DataTable dt = plugins.CreateDateTable(list); DataRow[] drs = dt.Select(string.Format("[Parent] = {0}", parent)); if (drs.Length == 0) { return; } else { foreach (DataRow dr in drs) { TreeNode tn = new TreeNode(); tn.Text = dr["Title"].ToString(); tn.Value = dr["Id"].ToString(); if (dt.Select(string.Format("[Parent] = {0}", tn.Value)).Length > 0) { tn.PopulateOnDemand = true; } tn.NavigateUrl = string.Format("AddIn.aspx?PluginId={0}", dr["Id"]); nodes.Add(tn); } } }
private void BuildItems(TreeNodeCollection items, bool isRoot, bool isExpanded, HtmlTextWriter writer) { if (items.Count > 0) { writer.WriteLine(); writer.WriteBeginTag("ul"); if (isRoot) { writer.WriteAttribute("id", this.ClientID); } writer.Write(HtmlTextWriter.TagRightChar); writer.Indent++; foreach (System.Web.UI.WebControls.TreeNode item in items) { BuildItem(item, writer); } writer.Indent--; writer.WriteLine(); writer.WriteEndTag("ul"); } }
public static void BindTreeByDataTable( TreeNodeCollection nodes, DataTable _idt, string sIDRoot, string sTextString, string sNavigateUrlString, string sValueString, string sToolTipString, string sTextField, string sNavigateUrlField, string sValueField, string sToolTipField) { foreach (DataRow idr in _idt.Rows) { if (idr[sValueField].ToString() == sIDRoot.TrimEnd()) { //子結點 BindTreeByDataTable(nodes, _idt, sTextString, idr[sValueField].ToString(), sNavigateUrlString, sValueString, sToolTipString, sTextField, sNavigateUrlField, sValueField, sToolTipField); //子內容 TreeNode newnode = new TreeNode(); newnode.Text = string.Format(sTextString, idr[sTextField].ToString()); newnode.NavigateUrl = string.Format(sNavigateUrlString, idr[sNavigateUrlField].ToString()); newnode.Value = string.Format(sValueString, idr[sValueField].ToString()); newnode.ToolTip = string.Format(sToolTipString, idr[sToolTipField].ToString()); newnode.Target = "e2content"; nodes.Add(newnode); } }//end foreach }//end BindTreeByDataTable
public void TreeNodeCollection_Method_Add () { TreeNodeCollection tnc = new TreeNodeCollection (); Assert.AreEqual (0, tnc.Count, "BeforeAdd"); tnc.Add (new TreeNode ("TreeNodeName")); Assert.AreEqual (1, tnc.Count, "AfterAdd1"); Assert.AreEqual ("TreeNodeName", tnc[0].Text, "AfterAdd2"); }
private static TreeNode GetTreeNode(string name, string value, TreeNodeCollection parent, PackagePreferences preferences) { TreeNode result = new TreeNode(name, value); result.ShowCheckBox = true; parent.Add(result); result.Checked = preferences == null || !preferences.IsInvalidPath(result.ValuePath); return result; }
public void TreeNodeCollection_Method_AddAt () { TreeNodeCollection tnc = new TreeNodeCollection (); tnc.Add (new TreeNode ()); tnc.Add (new TreeNode ()); Assert.AreEqual (2, tnc.Count, "BeforeAddAt"); tnc.AddAt (1, new TreeNode ("TreeNodeName")); Assert.AreEqual (3, tnc.Count, "AfterAddAt1"); Assert.AreEqual ("TreeNodeName", tnc[1].Text, "AfterAdd2"); }
/// <summary> /// 递归填充子节点 /// </summary> private static void FillChildren(DataRow parentType, TreeNodeCollection parentNode, DataTable dt) { foreach (var type in dt.Select(string.Format("PARENT_ID='{0}'", parentType["ID"]), "FUN_SORT ASC")) { var node = CreatNode(type); parentNode.Add(node); FillChildren(type, node.ChildNodes, dt); } }
private void SetSelectNodeUrls(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { node.NavigateUrl = "javascript:selectNode('" + node.Value + "','" + node.Text + "');"; SetSelectNodeUrls(node.ChildNodes); } }
//Populate tree node public void TreeNodePopulate(TreeNodeCollection nodes) { //Parents nodes treeNodes = authMgr.GetAllPermissionList(); CreateRootNode(nodes); //Children nodes //DataTable treeNodeChildren = new DataTable(); //treeNodeChildren = authMgr.getAllPermission(); //CreateTreeNode(treeNodeChildren, node); }
private void BuildNodes(TreeNode parent, TreeNodeCollection nodeCollectionToAddTo) { IEnumerable<TreeNode> nodes = _levelBuilders .Where(level => level.ShouldRun(parent)) .SelectMany(level => level.GetChildNodes(parent)); foreach (TreeNode node in nodes) { nodeCollectionToAddTo.Add(node); } }
private static string GetInnerXml(TreeNodeCollection childNodes, int offSet) { StringBuilder strBuilder = new StringBuilder(); string offsetStr = new string(' ', offSet); foreach (TreeNode childNode in childNodes) { strBuilder.Append(offsetStr + childNode.Text + "<br />"); strBuilder.Append(GetInnerXml(childNode.ChildNodes, offSet + 2)); } return strBuilder.ToString(); }
private void SaveNodes(System.Web.UI.WebControls.TreeNodeCollection destNodes, System.Windows.Forms.TreeNodeCollection sourceNodes) { destNodes.Clear(); foreach (TreeNodeContainer container in sourceNodes) { System.Web.UI.WebControls.TreeNode webTreeNode = container.WebTreeNode; destNodes.Add(webTreeNode); if (container.Nodes.Count > 0) { this.SaveNodes(webTreeNode.ChildNodes, container.Nodes); } } }
//递归调用显示子树 public void InitTree(TreeNodeCollection nds, string parentId) { TreeNode tn; DataSet dt = new DataSet(); DataRow[] rows = dt.Tables[0].Select("parent_Id='" + parentId + "'"); foreach (DataRow row in rows) { tn = new TreeNode(row["title"].ToString(), row["Files_Id"].ToString(), "images/1.gif", row["NavigateUrl"].ToString(), ""); nds.Add(tn); InitTree(tn.ChildNodes, row["Files_Id"].ToString()); //递归 } }
private void AddNodes(TreeNodeCollection nodes, int level, System.Data.DataTable dt) { string filterExp = string.Format("parentid='{0}'", level); foreach (System.Data.DataRow r in dt.Select(filterExp)) { TreeNode item = new TreeNode() { Text = r["name"].ToString(), Value = r["id"].ToString() }; this.AddNodes(item.ChildNodes, int.Parse(r["id"].ToString()), dt); nodes.Add(item); } }
/// <summary> /// Expands all tree elements with a depth less than the specified 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) { foreach (TreeNode node in nodes) { if (node.Depth < expandDepth) { node.Expand(); ExpandToDepth(node.ChildNodes, expandDepth); } } } }
public void SpecChildTree(TreeNodeCollection Nds, int SpecCateID) { TreeNode tmpNd; DataTable ds = this.dspec.GetSpecList(SpecCateID); foreach (DataRow dr in ds.Rows) { tmpNd = new TreeNode(); tmpNd.Value = dr["SpecID"].ToString(); tmpNd.Text = dr["SpecName"].ToString(); tmpNd.NavigateUrl = "SpecContent.aspx?SpecID=" + tmpNd.Value; tmpNd.Target = "main_right"; Nds.Add(tmpNd); } }
/// <summary> /// 专题选择的专题树 /// </summary> /// <param name="Nds"></param> public void InitTreeNode(TreeNodeCollection Nds) { TreeNode tmpNd; DataTable dtcate = dal.GetCateList(); foreach (DataRow dr in dtcate.Rows) { tmpNd = new TreeNode(); tmpNd.Value = dr["SpecCateID"].ToString(); tmpNd.Text = dr["SpecCateName"].ToString(); tmpNd.NavigateUrl = "javascript:category();"; tmpNd.Target = ""; Nds.Add(tmpNd); InitSpecTree(tmpNd.ChildNodes, DataConverter.CLng(tmpNd.Value)); } }
private void PopulateNodes(DataTable dt, TreeNodeCollection nodes) { foreach (DataRow dr in dt.Rows) { TreeNode tn = new TreeNode(); string namethai = BLL.Curriculum.renameThai(dr["StructSub_Code"].ToString()); tn.Text = dr["StructSub_Code"].ToString(); //+ "<br/> วิชา : " + namethai.Substring(0,5)+".."; tn.Value = dr["StructSub_Code"].ToString(); nodes.Add(tn); //If node has child nodes, then enable on-demand populating tn.PopulateOnDemand = ((int)(dr["childnodecount"]) > 0); } }
public void buildTree(TreeNodeCollection branch, Entities.SostavIzdeliaEntity item) { if (branch.Count > 0) { for (int i = 0; i < branch.Count; i++) { buildTree(branch[i].ChildNodes, item); if (branch[i].Value == item.idLast.ToString()) { TreeNode tn = new TreeNode(item.Current+" ("+ bll_unit_s.getProduction(item.idCurrent).DesignationProduction+") " + "["+item.count+"]", item.idCurrent.ToString()); branch[i].ChildNodes.Add(tn); } } } }
private void LoadNodes(System.Windows.Forms.TreeNodeCollection destNodes, System.Web.UI.WebControls.TreeNodeCollection sourceNodes) { foreach (System.Web.UI.WebControls.TreeNode node in sourceNodes) { TreeNodeContainer container = new TreeNodeContainer(); destNodes.Add(container); container.Text = node.Text; System.Web.UI.WebControls.TreeNode clone = (System.Web.UI.WebControls.TreeNode)((ICloneable)node).Clone(); this._treeViewDesigner.RegisterClone(node, clone); container.WebTreeNode = clone; if (node.ChildNodes.Count > 0) { this.LoadNodes(container.Nodes, node.ChildNodes); } } }
//Create root node private void CreateRootNode(TreeNodeCollection nodes) { DataRow[] arrDr = treeNodes.Select("Level = '0'"); String Id = arrDr[0]["Id"].ToString(); String Name = arrDr[0]["Name"].ToString(); String Sort = arrDr[0]["Sort"].ToString(); TreeNode newNode = new TreeNode(Name, Name); newNode.NavigateUrl = "#"; //newNode.PopulateOnDemand = true; //newNode.Expanded = true; nodes.Add(newNode); CreateTreeNode(newNode, Sort, 0); }
//�õݹ鷽����̬���ɽڵ� protected void InitTree(TreeNodeCollection Nds, string parentId) { DataView dv = new DataView(); TreeNode tmpNode; dv.Table = ProductTypeDataTable; dv.RowFilter = "PSSMEPMC='" + parentId + "'"; foreach (DataRowView drv in dv) { tmpNode = new TreeNode(); tmpNode.Value = drv["PSSMEMC"].ToString(); tmpNode.Text = "<font color=red><b>" + drv["PSSMEMC"].ToString() + "</b></font> " + drv["PSSMEMN"].ToString() + "/" + drv["PSSMEMNTW"].ToString() + "/" + drv["PSSMEMNEN"].ToString(); Nds.Add(tmpNode); this.InitTree(tmpNode.ChildNodes, tmpNode.Value); } }
private void ResolveTreeNode(TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { if (node.Nodes.Count == 0) { if (!String.IsNullOrEmpty(node.NavigateUrl)) { node.Target = "main"; } } else { ResolveTreeNode(node.Nodes); } } }
public void PopulateNodes(TreeNodeCollection nodes, int ParentID) { DataTable dt = bll.GetList(ParentID); for (int i = 0; i < dt.Rows.Count; i++) { TreeNode tn = new TreeNode(); tn.Text = dt.Rows[i]["catename"].ToString(); tn.Value = dt.Rows[i]["cateid"].ToString(); tn.ImageToolTip = dt.Rows[i]["catename"].ToString(); tn.ToolTip = dt.Rows[i]["catename"].ToString(); tn.SelectAction = TreeNodeSelectAction.Select; nodes.Add(tn); PopulateNodes(tn.ChildNodes, Convert.ToInt32(dt.Rows[i]["cateid"])); } }
private void InitTree(System.Web.UI.WebControls.TreeNodeCollection nodes, int parentID) { DataTable deptmentList = PersonnelAction.getDeptmentList(); DataRow[] array = deptmentList.Select("i_sjdm =" + parentID.ToString()); DataRow[] array2 = array; for (int i = 0; i < array2.Length; i++) { DataRow dataRow = array2[i]; System.Web.UI.WebControls.TreeNode treeNode = new System.Web.UI.WebControls.TreeNode(); treeNode.Value = dataRow["i_bmdm"].ToString(); treeNode.Text = dataRow["V_BMMC"].ToString(); treeNode.Target = "FraDuty"; treeNode.NavigateUrl = "DutyList.aspx?=DeptID=" + dataRow["i_bmdm"].ToString(); nodes.Add(treeNode); this.InitTree(treeNode.ChildNodes, Convert.ToInt32(treeNode.Value)); } }
private TreeNode FindTopicNodeRecursive(List<string> topics, TreeNodeCollection nodes) { foreach (TreeNode currentNode in nodes) { if (topics[0].Equals(currentNode.Text, StringComparison.Ordinal)) { topics.RemoveAt(0); if (topics.Count == 0) return currentNode; else if (!currentNode.Expanded.GetValueOrDefault(false)) // This call is required for nodes where PopulateOnDemand is true; // otherwise, ChildNodes is always empty. currentNode.Expand(); TreeNode foundNode = FindTopicNodeRecursive(topics, currentNode.ChildNodes); if (foundNode != null) return foundNode; } } return null; }
//�����Ļ���˼·�ǣ��Ӹ��ڵ㿪ʼ�ݹ������ʾ���� private void InitTree(TreeNodeCollection Nds,string parentId) { DataView dv=new DataView(); TreeNode tmpNd; string intId; dv.Table=ds.Tables[0]; dv.RowFilter="ST_FatherID='" + parentId + "'"; foreach(DataRowView drv in dv) { tmpNd=new TreeNode(); tmpNd.Value=drv["st_classID"].ToString(); tmpNd.Text=drv["st_className"].ToString(); if(st_class.IsHaveChild((int)drv["st_classID"])) tmpNd.ImageUrl="../image/NodeImg1.gif"; else tmpNd.ImageUrl="../image/NodeImg0.gif"; tmpNd.NavigateUrl = "ST_PdClass.aspx?st_classID=" + drv["st_classID"]; Nds.Add(tmpNd); intId=drv["st_fatherid"].ToString(); InitTree(tmpNd.ChildNodes,tmpNd.Value); } }
protected TreeNodeCollection GetSubNode(List<SysNavTree> trees, int PanelID, int ParentID) { TreeNodeCollection result = new TreeNodeCollection(); var nodeList = from l in trees where l.PanelID == PanelID && l.ParentID == ParentID select l; foreach (var node in nodeList) { TreeNode n = new TreeNode(node.Title, node.ID.ToS()); var sublist = from l in trees where l.PanelID == PanelID && l.ParentID == node.ID select l; if (sublist.Count() > 0) { var subnodes = GetSubNode(trees, PanelID, node.ID); foreach (TreeNode subnode in subnodes) { n.ChildNodes.Add(subnode); } } result.Add(n); } return result; }
private void PopulateNodes(TreeNodeCollection nodes, int parent) { try { ZhuJi.Portal.IDAL.IChannel channel = ZhuJi.AOP.Operator.WrapInterface(typeof(ZhuJi.Portal.NHibernateDAL.Channel)) as ZhuJi.Portal.IDAL.IChannel; IList<ZhuJi.Portal.Domain.Channel> list = channel.GetObjects(); ZhuJi.Portal.Domain.ChannelCollection channels = new ZhuJi.Portal.Domain.ChannelCollection(); DataTable dt = channels.CreateDateTable(list); DataRow[] drs = dt.Select(string.Format("[Parent] = {0}", parent)); if (drs.Length == 0) { return; } else { foreach (DataRow dr in drs) { TreeNode tn = new TreeNode(); tn.Text = string.Format("{0}({1})", dr["Title"].ToString(), dr["Id"].ToString()); tn.Value = dr["Id"].ToString(); if (dt.Select(string.Format("[Parent] = {0}", tn.Value)).Length > 0) { tn.PopulateOnDemand = true; } tn.SelectAction = TreeNodeSelectAction.Expand; nodes.Add(tn); } } } catch (Exception ex) { ShowMessage(ex); } }
private TreeNodeCollection GetFileSystemTree(string path) { TreeNodeCollection result = new TreeNodeCollection(); DirectoryInfo rootDirectory = new DirectoryInfo(path); DirectoryInfo[] directories; directories = rootDirectory.GetDirectories(); foreach (DirectoryInfo dir in directories) { TreeNode treeNode = new TreeNode(dir.Name); foreach (TreeNode tn in GetFileSystemTree(dir.FullName)) { treeNode.ChildNodes.Add(tn); } result.Add(treeNode); } return result; }
public WebTreeNodeCollection(System.Web.UI.WebControls.TreeNodeCollection nodes) { this.m_Nodes = nodes; }
internal TreeNodeCollectionEnumerator(TreeNodeCollection list) { this.list = list; this.index = -1; version = list._version; }