本文整理汇总了C#中System.Web.UI.WebControls.TreeNodeCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.Add方法的具体用法?C# TreeNodeCollection.Add怎么用?C# TreeNodeCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.TreeNodeCollection
的用法示例。
在下文中一共展示了TreeNodeCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TreeNodeCollection_Method_AddAt
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");
}
示例2: PopulateNodes1
private void PopulateNodes1(TreeNodeCollection nodes, int parent)
{
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 = 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("ContentItem.aspx?ChannelId={0}", dr["Id"]);
nodes.Add(tn);
}
}
}
示例3: BindTreeByDataTable
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
示例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: AddDirectory
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;
}
}
}
示例6: TreeNodeCollection_Method_Add
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");
}
示例7: GetTreeNode
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;
}
示例8: FillChildren
/// <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);
}
}
示例9: BuildNodes
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);
}
}
示例10: InitTree
//递归调用显示子树
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()); //递归
}
}
示例11: AddNodes
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);
}
}
示例12: SpecChildTree
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);
}
}
示例13: InitTreeNode
/// <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));
}
}
示例14: PopulateNodes
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);
}
}
示例15: PopulateNodes
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"]));
}
}