本文整理汇总了C#中System.Web.UI.WebControls.TreeNode类的典型用法代码示例。如果您正苦于以下问题:C# TreeNode类的具体用法?C# TreeNode怎么用?C# TreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeNode类属于System.Web.UI.WebControls命名空间,在下文中一共展示了TreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTreeNode
/// <summary>
/// Retrieves the differnt facet members to be placed into TreeNode objects for disaply
/// </summary>
/// <param name="name"></param>
/// <param name="f"></param>
/// <returns></returns>
private TreeNode GetTreeNode(string name, IElement f, string path)
{
TreeNode tn = new TreeNode();
IEnumerable<IModelMember> facetMembers = ContactFacetsHelper.FacetFactory.GetFacetMembers(f);
tn.Text = name;
tn.Value = path;
if (facetMembers != null && facetMembers.Any())
{
foreach (IModelMember modelMember in facetMembers)
{
if (modelMember is IModelAttributeMember && !string.Equals(modelMember.Name, "Preferred", StringComparison.OrdinalIgnoreCase))
{
var newItemPath = string.Format("{0}/{1}", path, modelMember.Name);
var newNode = new TreeNode(modelMember.Name, newItemPath);
newNode.Selected = newItemPath.ToLowerInvariant() == this.MappedFields.Value.ToLowerInvariant();
tn.ChildNodes.Add(newNode);
}
else if (modelMember is IModelElementMember)
{
IModelElementMember modelElementMember = modelMember as IModelElementMember;
tn.ChildNodes.Add(GetTreeNode(modelElementMember.Name, modelElementMember.Element, string.Format("{0}/{1}", path, modelElementMember.Name)));
}
else if (modelMember is IModelDictionaryMember || modelMember is IModelCollectionMember)
{
IModelDictionaryMember dictionaryMember = modelMember as IModelDictionaryMember;
Type type = dictionaryMember == null ? Enumerable.Single<Type>((IEnumerable<Type>)(modelMember as IModelCollectionMember).Elements.GetType().GetGenericArguments()) : Enumerable.Single<Type>((IEnumerable<Type>)dictionaryMember.Elements.GetType().GetGenericArguments());
if (!(type == (Type)null))
tn.ChildNodes.Add(GetTreeNode("Entries", ContactFacetsHelper.FacetFactory.CreateElement(type), string.Format("{0}/{1}", path, "Entries")));
}
}
}
return tn;
}
示例2: CreateSprengelAuswertung
private void CreateSprengelAuswertung (XmlDocument AuszaehlungsStand, TreeView AuszaehlungsTreeView)
{
TreeNode StiegenRootNode = new TreeNode ("Abgegebene Stimmen pro Stiege");
AuszaehlungsTreeView.Nodes.Add (StiegenRootNode);
XmlNode SprengelContainer = AuszaehlungsStand.DocumentElement.SelectSingleNode
("child::" + MBRStatics.MBR_SPRENGEL_DATEN);
foreach (XmlNode StiegenNode in SprengelContainer.SelectNodes("child::" + MBRStatics.MBR_SPRENGEL))
{
String Stiege = StiegenNode.Attributes[MBRStatics.MBR_STIEGE].Value.Replace("_", "/");
String Wohnungen = StiegenNode.SelectSingleNode("child::" + MBRStatics.MBR_WOHNUNGEN).InnerText;
String Schluessel = StiegenNode.SelectSingleNode("child::" + MBRStatics.MBR_SCHLUESSEL).InnerText;
XmlNode AbgegebenNode = StiegenNode.LastChild;
XmlNode ImZeitRaumNode = AbgegebenNode.LastChild;
if (ImZeitRaumNode == null)
continue;
XmlNode AlleNode = ImZeitRaumNode.LastChild;
String Abgegeben = AlleNode.InnerText;
TreeNode StiegenTreeNode = new TreeNode (Stiege + " - " + Wohnungen
+ "(" + Schluessel + ") "
+ Abgegeben + " Stimmen bisher abgegeben");
StiegenRootNode.ChildNodes.Add (StiegenTreeNode);
if (ImZeitRaumNode != null)
foreach (XmlNode Maschine in ImZeitRaumNode.ChildNodes)
{
TreeNode MaschinenNode = new TreeNode (Maschine.InnerText + " " + Maschine.Name);
StiegenTreeNode.ChildNodes.Add (MaschinenNode);
}
}
}
示例3: BindTreeView
/// <summary>
/// 绑定部门
/// </summary>
private void BindTreeView()
{
DataSet ds = mDpt.GetList(" ");
DataTable dt = new DataTable();
dt = ds.Tables[0];
DataRow[] drs = dt.Select(" Dpt_ParentId = 0"); //选出所有根节点
this.tvDaiLi.Nodes.Clear();
TreeNode RootNode = new TreeNode();
RootNode.Text = "<a href='SystemConfigMain.aspx?DPTId=0' onclick='aClick(this);' target='center' >组织机构</a>";
RootNode.Value = "0";
this.tvDaiLi.Nodes.Add(RootNode);
foreach (DataRow dr in drs)
{
string DPTId = dr["Dpt_Id"].ToString();
string DPTName = dr["Dpt_Name"].ToString();
string DPTPARENTID = dr["Dpt_ParentId"].ToString();
TreeNode RootNode2 = new TreeNode();
RootNode2.Text = "<a href='SystemConfigMain.aspx?DPTId=" + DPTId + "' onclick='aClick(this);' target='center' >" + DPTName + "</a>";
RootNode2.Value = DPTId;
RootNode.ChildNodes.Add(RootNode2);
string SonParentID = DPTId;
CreateNode(SonParentID, RootNode2, dt);
}
//this.tvDaiLi.CollapseAll();
}
示例4: InitTreeNode
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);
}
}
}
示例5: ShowSelectionTree
private void ShowSelectionTree ()
{
TreeView SelectionTreeView = new TreeView ();
SelectionTreeView.CssClass = "CSS_SelectionTreeView";
this.ContentPlaceHolderNavigationPlace.Controls.Add (SelectionTreeView);
LoadPossibleValues ();
TreeNode StartNode = new TreeNode ("Kalender Durchsuchen nach..");
StartNode.SelectAction = TreeNodeSelectAction.Expand;
SelectionTreeView.Nodes.Add (StartNode);
foreach (DataTable Table in PossibleValues.Tables)
{
String TableName = Table.TableName;
String ColumnName = Table.Columns [0].ColumnName;
TreeNode TableNode = new TreeNode (ColumnName);
TableNode.SelectAction = TreeNodeSelectAction.Expand;
StartNode.ChildNodes.Add (TableNode);
foreach (DataRow TableRow in Table.Rows)
{
String Entry = TableRow [0].ToString ();
TreeNode ContentNode = new TreeNode (Entry);
TableNode.ChildNodes.Add (ContentNode);
ContentNode.NavigateUrl = "./WPMediaCalendarDisplay.aspx?Search=Future&Table=Kalender"
+ "&Column=" + ColumnName + "&Entry=" + Entry;
}
TableNode.Collapse ();
}
}
示例6: btnAddNode_Click
protected void btnAddNode_Click(object sender, EventArgs e)
{
TreeNode myNode = new TreeNode();
myNode.Text = txbText.Text;
myNode.NavigateUrl = txbUrl.Text;
TreeView1.FindNode("Home/Finance/Markets").ChildNodes.Add(myNode);
}
示例7: AddTree
//递归添加树的节点
public void AddTree(int ParentID, TreeNode pNode)
{
DataSet ds = (DataSet)this.ViewState["ds"];
DataView dvTree = new DataView(ds.Tables[0]);
//过滤ParentID,得到当前的所有子节点
dvTree.RowFilter = "[c_parent_id] = " + ParentID;
foreach (DataRowView Row in dvTree)
{
TreeNode Node = new TreeNode();
if (pNode == null)
{ //添加根节点
Node.Text = Row["c_province_name"].ToString();
TreeView1.Nodes.Add(Node);
Node.Expanded = true;
AddTree(Int32.Parse(Row["c_id"].ToString()), Node); //再次递归
}
else
{ //̀添加当前节点的子节点
Node.Text = Row["c_province_name"].ToString();
pNode.ChildNodes.Add(Node);
Node.Expanded = true;
AddTree(Int32.Parse(Row["c_id"].ToString()), Node); //再次递归
}
}
}
示例8: LoadFolderNodes
protected void LoadFolderNodes(SPFolder folder, TreeNode folderNode)
{
foreach (SPFolder childFolder in folder.SubFolders)
{
TreeNode childFolderNode = new TreeNode(childFolder.Name, childFolder.Name, FOLDER_IMG);
childFolderNode.NavigateUrl = SPContext.Current.Site.MakeFullUrl(childFolder.Url);
LoadFolderNodes(childFolder, childFolderNode);
folderNode.ChildNodes.Add(childFolderNode);
}
foreach (SPFile file in folder.Files)
{
TreeNode fileNode;
if (file.CustomizedPageStatus == SPCustomizedPageStatus.Uncustomized)
{
fileNode = new TreeNode(file.Name, file.Name, GHOSTED_FILE_IMG);
}
else
{
fileNode = new TreeNode(file.Name, file.Name, UNGHOSTED_FILE_IMG);
}
fileNode.NavigateUrl = SPContext.Current.Site.MakeFullUrl(file.Url);
folderNode.ChildNodes.Add(fileNode);
}
}
示例9: RschPropsListBuilder
public static void RschPropsListBuilder(TreeView tw, int rschId)
{
var tasks = TaskManager.GetTasks(rschId).ToList<Task>();
List<TaskNode> taskNodes = new List<TaskNode>();
foreach (var task in tasks)
{
if (tw.Nodes.Count == 0)
{
tw.Nodes.Add(new TreeNode(TaskManager.GetTaskDescription(task.Type)));
tw.Nodes[0].ChildNodes.Add(new TreeNode(task.Value));
}
else
{
bool placed = false;
foreach (TreeNode n in tw.Nodes)
{
if (n.Text == TaskManager.GetTaskDescription(task.Type))
{
n.ChildNodes.Add(new TreeNode(task.Value));
placed = true;
}
}
if (!placed)
{
TreeNode tnode = new TreeNode(TaskManager.GetTaskDescription(task.Type));
tnode.ChildNodes.Add(new TreeNode(task.Value));
tw.Nodes.Add(tnode);
}
}
//taskNodes.Add(new TaskNode(){Description = TaskManager.GetTaskDescription(task.Type), Value = task.Value});
}
//TaskManager.GetTaskDescription(1);
}
示例10: GenerarMenu
/// <summary>
/// Genera el menu apartir de los resultados de la base de datos
/// </summary>
private void GenerarMenu()
{
List<MENU> menus = null;
List<MENU> menusPadres = null;
List<MENU> submenus = null;
TreeNode item;
TreeNode subitem;
menus = (List<MENU>)Session["Menu"];
menus = menus.OrderBy(menu => menu.NIVELMENU).ToList();
menusPadres = menus.Where(menu => menu.NIVELMENU == 0).ToList();
menusPadres.ForEach(padre =>
{
submenus = menus.Where(x => x.IDMENUPADRE == padre.IDMENU).ToList();
item = new TreeNode
{
Value = padre.DESCRIPCIONMENU,
NavigateUrl = padre.RUTA
};
TreeViewMenu.Nodes.Add(item);
submenus.ForEach(submenu =>
{
subitem = new TreeNode
{
Value = submenu.DESCRIPCIONMENU,
NavigateUrl = submenu.RUTA
};
item.ChildNodes.Add(subitem);
});
});
}
示例11: PopulateTreeView
int PopulateTreeView(TagElements parentTag, int curentPosition, TreeNode parentNode)
{
// parentTag.hierarchicalPosition = curentPosition;
int j = 0;
foreach (TagElements tag in tagMap)
{
if (tag == null) break;
if (tag.parentName == parentTag.tagName)
{
TreeNode curentNode = new TreeNode();
curentNode.Text = tag.tagName;
curentNode.NavigateUrl = "TagInfo.aspx?tagName=" + tag.tagName;
curentNode.Collapse();
parentNode.ChildNodes.Add(curentNode);
PopulateTreeView(tag, curentPosition + 1, curentNode);
}
j++;
// Response.Write(tag.tagName + " " + tag.parentName + "<br />");
}
return 0;
}
示例12: show_phongban
private void show_phongban()
{
try
{
execSQL.connectionClass ob = new execSQL.connectionClass();
DataSet ds = ob.fillDataset("EXEC ChungNT.KeHoach_TongHop_DonVi");
DataView dv = ds.Tables[0].DefaultView;
TreeNode child;
foreach (TreeNode node in tvPhongBan.Nodes)
{
dv.RowFilter = string.Format("GroupID = '{0}'", node.Value);
for (int i = 0; i < dv.Count; i++)
{
child = new TreeNode();
child.Value = dv[i][0].ToString();
child.Text = dv[i][1].ToString();
child.ShowCheckBox = true;
child.SelectAction = TreeNodeSelectAction.None;
node.ChildNodes.Add(child);
}
}
lbError.Text = "";
}
catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message; }
}
示例13: PopulateNodes2
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);
}
}
}
示例14: BindReportTreeData
/// <summary>
/// 绑定报表功能菜单树
/// </summary>
public void BindReportTreeData()
{
tvReport.Nodes.Clear();
DataTable dtReportCategory = WebReportCategoryBLL.Instance.GetAll();
List<TreeNode> nodes = WebReportCategory.WebReportCategoryTree.GetTree(dtReportCategory);
TreeNode root = new TreeNode();
root.Text = "报表功能菜单树";
root.Value = "0";
var listReportInfo = WebReportInfoBLL.Instance.GetAllList("DELETED = 0 and STATUS=1", "CATEGORYID");
int? categoryID = -1;
TreeNode findNode = null;
foreach (var item in listReportInfo)
{
if (categoryID != item.CATEGORYID)
{
findNode = TreeNodeHelper.GetNodeByID(nodes, "" + item.CATEGORYID);
}
if (findNode != null)
{
TreeNode childeNode = new TreeNode();
childeNode.Value = "Info_" + item.ID; //加Info_前缀的目的是防止ID和类别的ID相同
childeNode.Text = "" + item.NAME;
findNode.ChildNodes.Add(childeNode);
categoryID = item.CATEGORYID;
}
}
foreach (TreeNode node in nodes)
{
root.ChildNodes.Add(node);
}
tvReport.Nodes.Add(root);
}
示例15: buildBreadcrumbs
protected string buildBreadcrumbs(TreeNode startingNode)
{
if (startingNode == null)
return "<span class=\"breadCrumLabel\">Path</span>";
string internalValuePath = (string)startingNode.GetType().InvokeMember("InternalValuePath", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance, null, startingNode, null);
string postBackUrl = this.Page.ClientScript.GetPostBackClientHyperlink(this.tv, "s" + internalValuePath, true);
string breadcrumSeparatorImageUrl = this.getImageUrl("breadcrumseparator.gif");
string separator = String.Format("<span class=\"breadCrumSeparator\"> <img src=\"{0}\" alt=\">>\" title=\">>\" /> </span>", breadcrumSeparatorImageUrl);
string nodeText = startingNode.Parent != null ? startingNode.Text : "Storage";
string breadCrum;
if (startingNode == this.tv.SelectedNode)
{
string template = "<span class=\"breadCrumLast\" title=\"{1}\"><img src=\"{0}\" alt=\"{1}\" title=\"{1}\" /> {2}</span> ";
breadCrum = String.Format(template, startingNode.ImageUrl, Utility.QuoteJScriptString(startingNode.ToolTip, false), Utility.QuoteJScriptString(nodeText, false));
}
else
{
string template = "<a href=\"{0}\" title=\"{1}\" class=\"breadCrum\"><img src=\"{2}\" alt=\"{3}\" title=\"{3}\" /> {4}</a> ";
breadCrum = String.Format(template, postBackUrl, Utility.QuoteJScriptString(startingNode.ToolTip, false), startingNode.ImageUrl, Utility.QuoteJScriptString(startingNode.ToolTip, false), Utility.QuoteJScriptString(nodeText, false));
}
string result = this.buildBreadcrumbs(startingNode.Parent) + separator + breadCrum;
if (result.StartsWith(separator))
result = result.Substring(separator.Length);
return result;
}