本文整理汇总了C#中TreeView.ExpandAll方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.ExpandAll方法的具体用法?C# TreeView.ExpandAll怎么用?C# TreeView.ExpandAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeView
的用法示例。
在下文中一共展示了TreeView.ExpandAll方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTreeView
public static void GetTreeView(TreeView tv)
{
tv.Nodes.Clear();
//建立根節點
TreeNode Root = new TreeNode();
Root.Text = "Land Project";
tv.Nodes.Add(Root);//建立根节点
using (SqlConnection cn = new SqlConnection(ConnString))
{
if (cn.State != ConnectionState.Open) cn.Open();
using (SqlCommand cm = new SqlCommand(" Select Distinct Pid,Convert(Nvarchar(10),CreateTime) CreateTime From LandProject Order By CreateTime DESC", cn))
{
using (SqlDataReader dr = cm.ExecuteReader())
{
while (dr.Read())
{
TreeNode Node = new TreeNode();
Node.Text = dr["CreateTime"].ToString().Trim();
//Node.Target = "mainbottom";
//string Path = drNode["menu_addr"].ToString();
//int menusn = Convert.ToInt32(drNode["sn"].ToString());
Node.NavigateUrl = "LandProjectView.aspx" + "?Pid=" + dr["Pid"].ToString().Trim();
Root.ChildNodes.Add(Node);//建立子节点
}
}
}
}
tv.ExpandAll();
}
示例2: expandOrMinimizeTreeView
/* ---------------------------------------------------------
* ---------------- TREEVIEW (generic) --------------------
* --------------------------------------------------------
*/
private void expandOrMinimizeTreeView(TreeViewEvent tvEvent, TreeView tv)
{
if(tvEvent.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
tv.CollapseAll();
else if (tvEvent.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
tv.CollapseAll();
tvEvent.ExpandOptimal();
} else //MAXIMIZED
tv.ExpandAll();
//Log.WriteLine("IS " + tvEvent.ExpandState);
}
示例3: SetTreeNode
/// <summary>
/// Sets the text for the specified control in multithreading circumstances.
/// </summary>
/// <param name="control"></param>
/// <param name="text"></param>
public static void SetTreeNode(TreeView control, TreeNodeCollection val, String strc)
{
if (control != null)
{
string[] arrls = strc.Split(new char[] { '|' });
if (control.InvokeRequired)
{
SetTreeNodeSafe scts = new SetTreeNodeSafe(SetTreeNode);
control.Invoke(scts, new Object[] { control, val,strc });
}
else
{
if (String.IsNullOrEmpty(strc) == true)
{
for (int i = 0; i < val.Count; i++)
{
control.Nodes.Add(val[i]);
}
}
else
{
TreeNode pnode = null;
Int32 ik = 0;
foreach (var item in arrls)
{
if (ik == 0)
{
pnode = control.Nodes[SRLibFun.StringConvertToInt32(item)];
}
else
{
pnode = pnode.Nodes[SRLibFun.StringConvertToInt32(item)];
}
ik++;
}
for (int i = 0; i < val.Count; i++)
{
pnode.Nodes.Add(val[i]);
}
}
control.ExpandAll();
}
}
}