本文整理汇总了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} ", 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;
}
}
}
示例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");
}