当前位置: 首页>>代码示例>>C#>>正文


C# TreeNodeCollection.Remove方法代码示例

本文整理汇总了C#中System.Web.UI.WebControls.TreeNodeCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.Remove方法的具体用法?C# TreeNodeCollection.Remove怎么用?C# TreeNodeCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.UI.WebControls.TreeNodeCollection的用法示例。


在下文中一共展示了TreeNodeCollection.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PopulateNodes

        /// <summary>
        /// Populates the nodes.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="nodes">The nodes.</param>
        private void PopulateNodes(List<Category> list, TreeNodeCollection nodes)
        {
            foreach (Category c in list)
            {

                // Modified by Stewart Moss
                // 10-May-2009
                //
                // Fix for [BGN-938]  The Project Summary page cannot show long categories
                //
                // The category name is not truncated intelligently and long category names
                // break the category list in the project summary page.
                // (or anywhere else this control is used)
                //
                // This code performs the required truncation. An elipsis is also added.
                // This code does take bool ShowIssueCount in accout by adding 5 to the maxSize
                //
                // Example: The test category "this is a new test category ra ra ra" at a level 4 depth
                // exibits this problem.

                TreeNode tn = new TreeNode();
                nodes.Add(tn);
                try
                {
                    // Calculate the right trimming length
                    //
                    // This is not an exact science here, becuase tn.depth is not always right
                    int maxSize;
                    int tmpint = tn.Depth > 0 ? tn.Depth : 1;
                    maxSize = 35 - (((tmpint) - 1) * 2);
                    if (!ShowIssueCount) { maxSize += 5; }
                    // when the depth gets high, the formula goes wonky, so correct it
                    if (tmpint >= 5) maxSize -= 2;

                    // now cut it if it needs it
                    string tmpstr = c.Name;
                    if (tmpstr.Length > maxSize)
                    {
                        tmpstr = tmpstr.Remove(maxSize - 1) + ".."; // add an elipsis
                    }

                    if (ShowIssueCount)
                    {
                        tn.Text = String.Format("{0}</a></td><td style='width:100%;text-align:right;'><a>{1}&nbsp;", tmpstr, IssueManager.GetCountByProjectAndCategoryId(ProjectId, c.Id));
                        tn.NavigateUrl = String.Format("~/Issues/IssueList.aspx?pid={0}&c={1}", ProjectId, c.Id);
                    }
                    else
                    {
                        tn.Text = tmpstr;
                    }
                    tn.Value = c.Id.ToString();

                    //If node has child nodes, then enable on-demand populating
                    tn.PopulateOnDemand = (c.ChildCount > 0);
                }
                catch (Exception ex)
                {
                    nodes.Remove(tn);
                    throw ex;
                }
            }
        }
开发者ID:JackyW83,项目名称:Test,代码行数:67,代码来源:CategoryTreeView.ascx.cs

示例2: TreeNodeCollection_Method_Remove

		public void TreeNodeCollection_Method_Remove () {
			TreeNodeCollection tnc = new TreeNodeCollection ();
			TreeNode tn = new TreeNode ("second");
			tnc.Add (new TreeNode ("first"));
			tnc.Add (tn);
			tnc.Add (new TreeNode ("third"));
			Assert.AreEqual (3, tnc.Count, "BeforeRemove1");
			Assert.AreEqual ("second", tnc[1].Text, "BeforeRemove2");
			tnc.Remove (tn);
			Assert.AreEqual (2, tnc.Count, "AfterRemove1");
			Assert.AreEqual ("third", tnc[1].Text, "AfterRemove2");
		}
开发者ID:nobled,项目名称:mono,代码行数:12,代码来源:TreeNodeCollectionTest.cs


注:本文中的System.Web.UI.WebControls.TreeNodeCollection.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。