本文整理汇总了C#中TreeNodeCollection类的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection类的具体用法?C# TreeNodeCollection怎么用?C# TreeNodeCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeNodeCollection类属于命名空间,在下文中一共展示了TreeNodeCollection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTreeNodes
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
TreeNodeCollection nodes = new TreeNodeCollection();
TreeNode item = this.CreateTreeNode("-1", "-1", queryStrings, "");
nodes.Add(item);
return nodes;
}
示例2: GetNodes
public TreeNodeCollection GetNodes(string node)
{
TreeNodeCollection nodes = new TreeNodeCollection(false);
if (!string.IsNullOrEmpty(node))
{
for (int i = 1; i < 6; i++)
{
AsyncTreeNode asyncNode = new AsyncTreeNode();
asyncNode.Text = node + i;
asyncNode.NodeID = node + i;
nodes.Add(asyncNode);
}
for (int i = 6; i < 11; i++)
{
TreeNode treeNode = new TreeNode();
treeNode.Text = node + i;
treeNode.NodeID = node + i;
treeNode.Leaf = true;
nodes.Add(treeNode);
}
}
return nodes;
}
示例3: GetTreeNodes
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
var nodes = new TreeNodeCollection();
var item = this.CreateTreeNode("dashboard", id, queryStrings, "Applicaion Forms", "icon-truck", true);
nodes.Add(item);
return nodes;
}
示例4: BindTree
private void BindTree(TreeNodeCollection Nds, int IDStr)
{
SqlConnection Conn = new SqlConnection(ConfigurationManager.AppSettings["SQLConnectionString"].ToString());
Conn.Open();
SqlCommand MyCmd = new SqlCommand("select * from ERPBuMen where DirID=" + IDStr.ToString() + " order by ID asc", Conn);
SqlDataReader MyReader = MyCmd.ExecuteReader();
while (MyReader.Read())
{
TreeNode OrganizationNode = new TreeNode();
OrganizationNode.Text = MyReader["BuMenName"].ToString();
OrganizationNode.Value = MyReader["ID"].ToString();
int strId = int.Parse(MyReader["ID"].ToString());
OrganizationNode.ImageUrl = "~/images/user_group.gif";
OrganizationNode.SelectAction = TreeNodeSelectAction.Expand ;
string ChildID = ZWL.DBUtility.DbHelperSQL.GetSHSLInt("select top 1 ID from ERPBuMen where DirID=" + MyReader["ID"].ToString() + " order by ID asc");
if (ChildID.Trim() != "0")
{
//需要父项目一起选中,如果父项目不需要的话,请不要注释掉下面的行
//HaveChild = HaveChild + "|" + MyReader["BuMenName"].ToString() + "|";
}
OrganizationNode.ToolTip = MyReader["BuMenName"].ToString();
OrganizationNode.Expand();
Nds.Add(OrganizationNode);
//递归循环
BindTree(Nds[Nds.Count - 1].ChildNodes, strId);
}
MyReader.Close();
Conn.Close();
}
示例5: GetTreeNodes
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
var collection = new TreeNodeCollection();
switch (id)
{
case "settings":
collection.Add(CreateTreeNode("shipping", "settings", queryStrings, "Shipping", "icon-truck", false, "merchello/merchello/Shipping/manage"));
collection.Add(CreateTreeNode("taxation", "settings", queryStrings, "Taxation", "icon-piggy-bank", false, "merchello/merchello/Taxation/manage"));
collection.Add(CreateTreeNode("payment", "settings", queryStrings, "Payment", "icon-bill-dollar", false, "merchello/merchello/Payment/manage"));
collection.Add(CreateTreeNode("notifications", "settings", queryStrings, "Notifications", "icon-chat", false, "merchello/merchello/Notifications/manage"));
collection.Add(CreateTreeNode("gateways", "settings", queryStrings, "Gateway Providers", "icon-trafic", false, "merchello/merchello/GatewayProviders/manage"));
break;
case "reports":
collection.Add(CreateTreeNode("salesOverTime", "reports", queryStrings, "Sales Over Time", "icon-loading", false, "merchello/merchello/SalesOverTime/manage"));
collection.Add(CreateTreeNode("salesByItem", "reports", queryStrings, "Sales By Item", "icon-barcode", false, "merchello/merchello/SalesByItem/manage"));
collection.Add(CreateTreeNode("taxesByDestination", "reports", queryStrings, "Taxes By Destination", "icon-piggy-bank", false, "merchello/merchello/TaxesByDestination/manage"));
break;
default:
collection.Add(CreateTreeNode("catalog", "", queryStrings, "Catalog", "icon-barcode", false, "merchello/merchello/ProductList/manage"));
collection.Add(CreateTreeNode("orders", "", queryStrings, "Orders", "icon-receipt-dollar", false, "merchello/merchello/OrderList/manage"));
collection.Add(CreateTreeNode("settings", "", queryStrings, "Settings", "icon-settings", true, "merchello/merchello/Settings/manage"));
break;
}
return collection;
}
示例6: RestoreTreeViewState
private void RestoreTreeViewState(TreeNodeCollection nodes, List<string> list)
{
foreach (TreeNode node in nodes)
{
//
// Restore the state of one node.
//
if (list.Contains(node.Text))
{
if (node.ChildNodes != null && node.ChildNodes.Count != 0 && node.Expanded.HasValue && node.Expanded == false)
node.Expand();
}
else
{
if (node.ChildNodes != null && node.ChildNodes.Count != 0 && node.Expanded.HasValue && node.Expanded == true)
node.Collapse();
}
//
// If the node has child nodes, restore their state, too.
//
if (node.ChildNodes != null && node.ChildNodes.Count != 0)
RestoreTreeViewState(node.ChildNodes, list);
}
}
示例7: AddNode
public override TreeNode AddNode(IMaxNode wrapper, TreeNodeCollection parentCol)
{
TreeNode tn = base.AddNode(wrapper, parentCol);
MaterialWrapper mtlWrapper = wrapper as MaterialWrapper;
if (mtlWrapper != null)
{
AddObjects(mtlWrapper, tn.Nodes);
AddTextureMaps(mtlWrapper, tn.Nodes);
foreach (IMtl mtl in mtlWrapper.ChildMaterials)
{
this.AddNode(mtl, tn.Nodes);
}
}
else if (!(wrapper is INodeWrapper))
{
foreach (IMaxNode node in wrapper.ChildNodes)
{
this.AddNode(node, tn.Nodes);
}
}
return tn;
}
示例8: SetSelect
private bool SetSelect(string strSelected, TreeNodeCollection nodes)
{
if (nodes != null
&& nodes.Count > 0
)
{
foreach (TreeNode node in nodes)
{
if (node != null
)
{
if (
!PubClass.IsNull(node.Value)
&& node.Value == strSelected
)
{
node.Select();
return true;
}
else if (node.ChildNodes != null
&& node.ChildNodes.Count > 0
)
{
bool success = SetSelect(strSelected, node.ChildNodes);
// 如果成功了,就不往下继续查找了;
if (success)
return true;
}
}
}
}
return false;
}
示例9: ChoiceTreeNode
/// <summary>
///
/// </summary>
/// <param name="tnc"></param>
protected void ChoiceTreeNode(TreeNodeCollection tnc,List<RoleMoudleInfo> info)
{
foreach (TreeNode node in tnc)
{
RoleMoudleInfo Info = info.Find(delegate(RoleMoudleInfo info1)
{
return info1.MoudleId == int.Parse(node.Value);
});
if (node.ChildNodes.Count != 0)
{
if (Info!=null)
{
node.Checked = true;
}
ChoiceTreeNode(node.ChildNodes, info);
}
else
{
if (Info != null)
{
node.Checked = true;
}
}
}
}
示例10: BindBuMenTree
public void BindBuMenTree(TreeNodeCollection Nds, int IDStr)
{
DataSet MYDT=ZWL.DBUtility.DbHelperSQL.GetDataSet("select * from ERPBuMen where DirID=" + IDStr.ToString() + " order by ID asc");
for(int i=0;i<MYDT.Tables[0].Rows.Count;i++)
{
TreeNode OrganizationNode = new TreeNode();
string CharManStr = "";
if (MYDT.Tables[0].Rows[i]["ChargeMan"].ToString().Trim().Length <= 0)
{
CharManStr = "<font color=\"Red\">[未设置负责人]</font>";
}
else
{
CharManStr = MYDT.Tables[0].Rows[i]["ChargeMan"].ToString().Trim();
}
OrganizationNode.Text = MYDT.Tables[0].Rows[i]["BuMenName"].ToString() + " 部门主管:" + CharManStr;
OrganizationNode.ToolTip = "部门主管:" + MYDT.Tables[0].Rows[i]["ChargeMan"].ToString() + "\n电话:" + MYDT.Tables[0].Rows[i]["TelStr"].ToString() + "\n传真:" + MYDT.Tables[0].Rows[i]["ChuanZhen"].ToString() + "\n备注:" + MYDT.Tables[0].Rows[i]["BackInfo"].ToString();
OrganizationNode.Value = MYDT.Tables[0].Rows[i]["ID"].ToString();
int strId = int.Parse(MYDT.Tables[0].Rows[i]["ID"].ToString());
OrganizationNode.ImageUrl = "~/images/user_group.gif";
OrganizationNode.SelectAction = TreeNodeSelectAction.Expand;
OrganizationNode.Expand();
Nds.Add(OrganizationNode);
//递归循环
BindBuMenTree(Nds[Nds.Count - 1].ChildNodes, strId);
}
}
示例11: PerformGetTreeNodes
/// <summary>
/// Gets the tree nodes for the given id
/// </summary>
/// <param name="id"></param>
/// <param name="queryStrings"></param>
/// <returns></returns>
/// <remarks>
/// If the content item is a container node then we will not return anything
/// </remarks>
protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
{
var nodes = new TreeNodeCollection();
var entities = GetChildEntities(id);
nodes.AddRange(entities.Select(entity => GetSingleTreeNode(entity, id, queryStrings)).Where(node => node != null));
return nodes;
}
示例12: BuildFirstLevel
public static TreeNodeCollection BuildFirstLevel()
{
string path = HttpContext.Current.Server.MapPath("~/Examples/");
DirectoryInfo root = new DirectoryInfo(path);
DirectoryInfo[] folders = root.GetDirectories();
folders = SortFolders(root, folders);
TreeNodeCollection nodes = new TreeNodeCollection(false);
foreach (DirectoryInfo folder in folders)
{
if ((folder.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
excludeList.Contains(folder.Name) || folder.Name.StartsWith("_"))
{
continue;
}
ExampleConfig cfg = new ExampleConfig(folder.FullName + "\\config.xml", false);
string iconCls = string.IsNullOrEmpty(cfg.IconCls) ? "" : cfg.IconCls;
AsyncTreeNode node = new AsyncTreeNode();
node.Text = MarkNew(folder.FullName, folder.Name.Replace("_", " "));
node.IconCls = iconCls;
string url = PhysicalToVirtual(folder.FullName + "/");
node.NodeID = "e" + Math.Abs(url.ToLower().GetHashCode());
nodes.Add(node);
}
return nodes;
}
示例13: GetTreeNodes
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
if (id == "-1")
{
var nodes = new TreeNodeCollection();
var allContacts = this.CreateTreeNode("dashboard", id, queryStrings, "All Contact Message", "icon-list", false);
var repliedContacts = this.CreateTreeNode("replied", id, queryStrings, "Replied Contact Message", "icon-check", false);
var unRepliedContacts = this.CreateTreeNode("unreplied", id, queryStrings, "Un-Replied Contact Message", "icon-time", false);
var spamContacts = this.CreateTreeNode("spam", id, queryStrings, "Spam", "icon-squiggly-line", false);
var trashedContacts = this.CreateTreeNode("deleted", id, queryStrings, "Deleted", "icon-trash", false);
var settingsContacts = this.CreateTreeNode("settings", id, queryStrings, "Settings", "icon-wrench", false);
repliedContacts.RoutePath = "/uContactor/uContactorSection/replied/0";
unRepliedContacts.RoutePath = "/uContactor/uContactorSection/unreplied/0";
spamContacts.RoutePath = "/uContactor/uContactorSection/spam/0";
trashedContacts.RoutePath = "/uContactor/uContactorSection/deleted/0";
settingsContacts.RoutePath = "/uContactor/uContactorSection/settings/0";
nodes.Add(allContacts);
nodes.Add(repliedContacts);
nodes.Add(unRepliedContacts);
nodes.Add(spamContacts);
nodes.Add(trashedContacts);
nodes.Add(settingsContacts);
return nodes;
}
throw new NotImplementedException();
}
示例14: ReadNodes
private void ReadNodes( string path, TreeNodeCollection nodes, string selectedPath )
{
foreach( TreeNode node in nodes )
{
string childPath = path + "/" + GetNodeText( node ).Replace( '/', '_' );
bool expand = ControlPreferences.GetValue( Name, childPath ) == "Expanded";
bool collapse = ControlPreferences.GetValue( Name, childPath ) == "Collapsed";
bool select = (childPath == selectedPath);
if( expand )
{
_treeControl.ExpandNode( node );
ReadNodes( childPath, node.ChildNodes, selectedPath );
}
else if( collapse )
{
_treeControl.CollapseNode( node );
}
if( select )
{
_treeControl.SelectedNode = node;
}
}
}
示例15: GetTreeNodes
/// <summary>
/// Returns all section tree nodes
/// </summary>
/// <param name="id">Node's id.</param>
/// <param name="queryStrings">Query strings</param>
/// <returns>Collection of tree nodes</returns>
protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
{
var nodes = new TreeNodeCollection();
var ctrl = new WebsiteApiController();
if (id == Constants.System.Root.ToInvariantString())
{
var item = CreateTreeNode("0", "-1", queryStrings, "Websites", "icon-folder", true);
nodes.Add(item);
return nodes;
}
else if (id == "0")
{
foreach (var website in ctrl.GetAll())
{
var node = CreateTreeNode(
website.Id.ToString(),
"0",
queryStrings,
website.ToString(),
"icon-document",
false);
nodes.Add(node);
}
return nodes;
}
throw new NotSupportedException();
}