本文整理汇总了C#中System.Windows.Forms.TreeNode.Expand方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.Expand方法的具体用法?C# TreeNode.Expand怎么用?C# TreeNode.Expand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNode
的用法示例。
在下文中一共展示了TreeNode.Expand方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildCyberwareTree
/// <summary>
/// Build up the Tree for the current piece of Cyberware and all of its children.
/// </summary>
/// <param name="objCyberware">Cyberware to iterate through.</param>
/// <param name="objParentNode">TreeNode to append to.</param>
/// <param name="objMenu">ContextMenuStrip that the new Cyberware TreeNodes should use.</param>
/// <param name="objGearMenu">ContextMenuStrip that the new Gear TreeNodes should use.</param>
public void BuildCyberwareTree(Cyberware objCyberware, TreeNode objParentNode, ContextMenuStrip objMenu, ContextMenuStrip objGearMenu)
{
TreeNode objNode = new TreeNode();
objNode.Text = objCyberware.DisplayName;
objNode.Tag = objCyberware.InternalId;
if (objCyberware.Notes != string.Empty)
objNode.ForeColor = Color.SaddleBrown;
objNode.ToolTipText = objCyberware.Notes;
objNode.ContextMenuStrip = objMenu;
objParentNode.Nodes.Add(objNode);
objParentNode.Expand();
foreach (Cyberware objChild in objCyberware.Children)
BuildCyberwareTree(objChild, objNode, objMenu, objGearMenu);
foreach (Gear objGear in objCyberware.Gear)
{
TreeNode objGearNode = new TreeNode();
objGearNode.Text = objGear.DisplayName;
objGearNode.Tag = objGear.InternalId;
if (objGear.Notes != string.Empty)
objGearNode.ForeColor = Color.SaddleBrown;
objGearNode.ToolTipText = objGear.Notes;
objGearNode.ContextMenuStrip = objGearMenu;
BuildGearTree(objGear, objGearNode, objGearMenu);
objNode.Nodes.Add(objGearNode);
objNode.Expand();
}
}
示例2: AddNewNode
/// <summary>
/// Adds a new node to the selected node.
/// </summary>
public void AddNewNode()
{
if (SelectedNode == null)
{
MessageBox.Show("Please select a node first.");
return;
}
if (!SelectedNode.Text.Equals("Attributes", StringComparison.OrdinalIgnoreCase) && !SelectedNode.Text.Equals("Elements", StringComparison.OrdinalIgnoreCase))
{
MessageBox.Show("Please select either an 'attributes' or 'elements' node before attempting to add an item.");
return;
}
String nodename = GetTextInput();
if (nodename != "")
{
foreach (TreeNode node in SelectedNode.Nodes)
{
if (node.Text == nodename)
{
MessageBox.Show("Node already exists.");
return;
}
}
if (nodename.Equals("attributes", StringComparison.OrdinalIgnoreCase) || nodename.Equals("elements", StringComparison.OrdinalIgnoreCase))
{
MessageBox.Show("Name is invalid.");
return;
}
var newnode = new TreeNode(nodename);
SelectedNode.Nodes.Add(newnode);
SelectedNode.Expand();
if (SelectedNode.Text.Equals("Attributes", StringComparison.OrdinalIgnoreCase))
{
var valuenode = new TreeNode(GetTextInput("Please enter the value of the new attribute."));
newnode.Nodes.Add(valuenode);
newnode.Expand();
}
if (SelectedNode.Text.Equals("Elements", StringComparison.OrdinalIgnoreCase))
{
var attribnode = new TreeNode("Attributes");
var elenode = new TreeNode("Elements");
newnode.Nodes.Add(attribnode);
newnode.Nodes.Add(elenode);
newnode.Expand();
}
}
}
示例3: ShowDialog
/// <summary>
/// Displays the available areas in a tree view.
/// </summary>
/// <param name="session">The session.</param>
/// <returns></returns>
public NodeId ShowDialog(Session session)
{
m_session = session;
TreeNode root = new TreeNode(BrowseNames.Server);
root.Nodes.Add(new TreeNode());
BrowseTV.Nodes.Add(root);
root.Expand();
// display the dialog.
if (ShowDialog() != DialogResult.OK)
{
return null;
}
// ensure selection is valid.
if (BrowseTV.SelectedNode == null)
{
return null;
}
// get the selection.
ReferenceDescription reference = (ReferenceDescription)BrowseTV.SelectedNode.Tag;
if (reference == null)
{
return ObjectIds.Server;
}
// return the result.
return (NodeId)reference.NodeId;
}
示例4: BindEmployeeTree
//绑定员工树
private void BindEmployeeTree()
{
tvEmployee.Nodes.Clear();
Organization rootOrg = oBll.GetOrganization(1);
TreeNode root=new TreeNode();
root.Text=rootOrg.OName;
root.Tag=rootOrg.OId;
root.ImageKey = "folder";
root.SelectedImageKey = "folder";
IList<Employee> lstEmployee = eBll.GetEmployeeByOrgId(rootOrg.OId);
foreach (Employee e in lstEmployee)
{
TreeNode eNode = new TreeNode();
eNode.Text = e.EName + "(" + e.Code + ")";
eNode.Tag = "E_" + e.EId;
eNode.ImageKey = "person";
eNode.SelectedImageKey = "person";
root.Nodes.Add(eNode);
}
root.Expand();
CreateChildNode(ref root, rootOrg.OId);
tvEmployee.Nodes.Add(root);
}
示例5: InitializeOutlookbar
private void InitializeOutlookbar()
{
this.treeViewTask.Nodes.Clear();
TreeNode nodeRoot = new TreeNode();
nodeRoot.Text = "CSharpGoWinFormWinForm";
nodeRoot.Tag = -1;
this.treeViewTask.Nodes.Add(nodeRoot);
foreach (string strModule in Frm_Main.m_dicFormText2FormTypeName.Keys)
{
TreeNode node = new TreeNode();
node.Text = strModule;
node.Tag = 0;
node.ImageIndex = 0;
nodeRoot.Nodes.Add(node);
foreach (string strItem in Frm_Main.m_dicFormText2FormTypeName[strModule].Keys)
{
TreeNode nodeChild = new TreeNode();
nodeChild.Text = strItem;
nodeChild.Tag = 1;
nodeChild.ImageIndex = 1;
node.Nodes.Add(nodeChild);
}
}
this.treeViewTask.SelectedNode = this.treeViewTask.TopNode;
nodeRoot.Expand();
}
示例6: RefreshDevices
private void RefreshDevices()
{
tv_dirs.Nodes.Clear();
lv_files.Clear();
if ( devices != null )
{
foreach ( Device dev in devices ) dev.Close();
}
devices = Device.GetPhysicalDevices();
foreach ( Device dev in devices )
{
TreeNode root_node = new TreeNode( dev.DeviceName );
root_node.ImageIndex = 0;
root_node.SelectedImageIndex = 0;
tv_dirs.Nodes.Add( root_node );
List< FileSystem > filesystems = dev.GetFileSystems();
foreach ( FileSystem fs in filesystems )
{
FileNode node = new FileNode( fs.GetRootDir(), true );
root_node.Nodes.Add( node );
}
root_node.Expand();
}
}
示例7: BtnAddNewClick
private void BtnAddNewClick(object sender, EventArgs e)
{
if (treeXML.SelectedNode != null)
{
if (treeXML.SelectedNode.Text == "Attributes" || treeXML.SelectedNode.Text == "Elements")
{
String nodename = Microsoft.VisualBasic.Interaction.InputBox("Please enter the name of the new node.", "New Node Creation");
if (nodename != "")
{
foreach (TreeNode node in treeXML.SelectedNode.Nodes)
{
if (node.Text == nodename)
{
MessageBox.Show("Node already exists.");
return;
}
}
if (nodename.ToLower() == "attributes" || nodename.ToLower() == "elements")
{
MessageBox.Show("Name is invalid.");
}
else
{
var newnode = new TreeNode(nodename);
treeXML.SelectedNode.Nodes.Add(newnode);
treeXML.SelectedNode.Expand();
if (treeXML.SelectedNode.Text == "Attributes")
{
var valuenode = new TreeNode("value");
newnode.Nodes.Add(valuenode);
newnode.Expand();
}
if (treeXML.SelectedNode.Text == "Elements")
{
var attribnode = new TreeNode("Attributes");
var elenode = new TreeNode("Elements");
newnode.Nodes.Add(attribnode);
newnode.Nodes.Add(elenode);
newnode.Expand();
}
}
}
}
else
{
MessageBox.Show("Please select either an 'attributes' or 'elements' node before attempting to add an item.");
}
}
else
{
MessageBox.Show("Please select a node first.");
}
}
示例8: Show
public void Show(TreeView treeView)
{
TreeNode rootNode = new TreeNode("Tags");
ShowTreeView(rootNode, tagsStorage);
rootNode.Expand();
treeView.Nodes.Add(rootNode);
}
示例9: Add
private void Add(TreeNode parent)
{
TreeNode node = null;
string str = System.Design.SR.GetString("BaseNodeName");
if (parent == null)
{
int num;
this.NextNode = (num = this.NextNode) + 1;
int num2 = num;
node = this.treeView1.Nodes.Add(str + num2.ToString(CultureInfo.InvariantCulture));
node.Name = node.Text;
}
else
{
int num3;
this.NextNode = (num3 = this.NextNode) + 1;
int num4 = num3;
node = parent.Nodes.Add(str + num4.ToString(CultureInfo.InvariantCulture));
node.Name = node.Text;
parent.Expand();
}
if (parent != null)
{
this.treeView1.SelectedNode = parent;
}
else
{
this.treeView1.SelectedNode = node;
this.SetNodeProps(node);
}
}
示例10: BindTree
private void BindTree()
{
var mf = Utils.GetMainForm();
if (mf != null)
{
var nodes = new List<TreeNode>();
var ms = mf.Menus.OrderBy(m => m.OrderNum);
foreach (var tm in ms)
{
if (tm.ParentId != Guid.Empty)
{
continue;
}
var tn = new TreeNode();
tn.Text = tm.MenuName;
tn.Tag = tm;
foreach (var sm in ms)
{
if (tm.Id != sm.ParentId)
{
continue;
}
var sn = new TreeNode();
sn.Text = sm.MenuName;
sn.Tag = sm;
tn.Nodes.Add(sn);
}
tn.Expand();
nodes.Add(tn);
}
treeView1.Nodes.AddRange(nodes.ToArray());
}
}
示例11: AddNode
public void AddNode(TreeNode parentNode)
{
DataRow[] foundRows;
TreeNode newNode;
foundRows = MainForm.theUserpermission.Tables[0].Select("Parent_Menu_code = '" + parentNode.Tag.ToString() + "'");
if (foundRows.Length > 0)
{
for (int i = 0; i < foundRows.Length; i++)
{
newNode = new TreeNode();
newNode.Text = foundRows[i]["Permission_name"].ToString();
newNode.Tag = foundRows[i]["Permission_code"].ToString();
if (foundRows[i]["If_form"].ToString() != "True")
{
newNode.ImageIndex = 0;
newNode.SelectedImageIndex = 0;
}
else
{
newNode.ImageIndex = 1;
newNode.SelectedImageIndex = 1;
}
parentNode.Nodes.Add(newNode);
newNode.Expand();
}
treeView1.ExpandAll();
}
}
示例12: FormSelectSchema
public FormSelectSchema(DocProject project) : this()
{
this.m_project = project;
foreach (DocSection docSection in project.Sections)
{
if (docSection.Schemas.Count > 0)
{
TreeNode tnSection = new TreeNode();
tnSection.Tag = docSection;
tnSection.Text = docSection.Name;
tnSection.ImageIndex = 1;
this.treeView.Nodes.Add(tnSection);
foreach (DocSchema docSchema in docSection.Schemas)
{
TreeNode tnSchema = new TreeNode();
tnSchema.Tag = docSchema;
tnSchema.Text = docSchema.Name;
tnSchema.ImageIndex = 0;
tnSection.Nodes.Add(tnSchema);
}
tnSection.Expand();
}
}
}
示例13: FillLinkNode
public static void FillLinkNode(TreeNode linkNode)
{
linkNode.Nodes.Clear();
KeyValuePair<string, int> pair = (KeyValuePair<string, int>)linkNode.Tag;
ORM.DB_University.connection = DbProvider.GetConnection(pair.Key);
if (ORM.DB_University.connection.State != ConnectionState.Open)
{
ORM.DB_University.connection.Open();
}
TreeNode linkedObject = FormNavigator.UObjectTotreeNode(ORM.DB_University.GetObjectById(pair.Value));
linkNode.Nodes.Add(linkedObject);
FormNavigator.FillNode(linkedObject);
linkNode.Expand();
ORM.DB_University.connection.Close();
ORM.DB_University.RestorePrimaryConnection();
}
示例14: WhereUsedMenuItem_Click
private void WhereUsedMenuItem_Click(object sender, EventArgs e)
{
TreeNode node;
TreeNode newNode = new TreeNode();
Urn[] urns = new Urn[1];
Scripter scripter;
// Get selected node
node = this.DependenciesTreeView.SelectedNode;
// Only do this once
if (node.Nodes.ContainsKey(Properties.Resources.UsedBy) == true
| node.Name == Properties.Resources.UsedBy)
{
return;
}
// Get the urn from the node
urns[0] = (Urn)(node.Tag);
// Add a "where used" node
newNode = new TreeNode(Properties.Resources.UsedBy);
newNode.Name = Properties.Resources.UsedBy;
node.Nodes.Add(newNode);
// And add the tree to the current node
scripter = new Scripter(server);
AddChildren(newNode, scripter.DiscoverDependencies(urns, DependencyType.Children).FirstChild);
node.Expand();
newNode.Expand();
}
示例15: CreateTreeViewRecursiveNew
public void CreateTreeViewRecursiveNew(TreeNode nodes, DataTable dataSource, DataTable dataAct, string parentId)
{
DataView dv = new DataView(dataSource);
if (parentId == "0")
dv.RowFilter = "parent_sub_project_id='0'";
else
dv.RowFilter = "parent_sub_project_id='" + parentId + "'";
foreach (DataRowView dr in dv)
{
TreeNode node = new TreeNode();
node.Text = dr["sub_project_id"].ToString() + " " + dr["description"].ToString();
node.Tag = dr["sub_project_id"].ToString();
node.Name = dr["description"].ToString();
node.ImageIndex = 2;
node.SelectedImageIndex = 2;
nodes.Nodes.Add(node);
DataView dv1 = new DataView(dataAct);
dv1.RowFilter = "sub_project_id='" + dr["sub_project_id"].ToString() + "'";
foreach (DataRowView act in dv1)
{
TreeNode tn_act = new TreeNode();
tn_act.Name = "activity";
tn_act.Tag = act["activity_seq"].ToString();
tn_act.Text = act["activity_no"].ToString() + " " + act["description"].ToString();
tn_act.SelectedImageIndex = 4;
tn_act.ImageIndex = 4;
node.Nodes.Add(tn_act);
}
CreateTreeViewRecursiveNew(node, dataSource, dataAct, dr["sub_project_id"].ToString());
}
if (parentId == "0")
nodes.Expand();
}