本文整理汇总了C#中System.Windows.Forms.TreeNode类的典型用法代码示例。如果您正苦于以下问题:C# TreeNode类的具体用法?C# TreeNode怎么用?C# TreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TreeNode类属于System.Windows.Forms命名空间,在下文中一共展示了TreeNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RecurrsiveSearch
private TreeNode RecurrsiveSearch(int id)
{
Hash source = Project.Data.MapInfos;
var mapInfo = source[id] as MapInfo;
if (mapInfo != null)
{
var node = new TreeNode
{
Name = id.ToString(),
ImageIndex = 1,
SelectedImageIndex = 1,
Text = mapInfo.name,
Tag = mapInfo
};
foreach (MapInfo info in source.Values)
{
int childId = source.GetKey(info);
if (info.parent_id == id && !_skipIds.Contains(childId))
{
_skipIds.Add(childId);
node.Nodes.Add(RecurrsiveSearch(childId));
}
}
return node;
}
return null;
}
示例2: AddProjectNode
public TreeNode AddProjectNode(TreeNode motherNode, IProject project)
{
ProjectNode projectNode = new ProjectNode(project);
projectNode.AddTo(motherNode);
ReferenceFolder referenceFolderNode = new ReferenceFolder(project);
referenceFolderNode.AddTo(projectNode);
//TagManagerNode tagManagerNode = new TagManagerNode(project);
//tagManagerNode.AddTo(projectNode);
//
// TagListFileNode tagListFileNode = new TagListFileNode(TagManager.FullFileName, FileNodeStatus.InProject);
// tagListFileNode.AddTo(projectNode);
// TagGroupNode tagGroupNode = new TagGroupNode(project);
// tagGroupNode.AddTo(projectNode);
// AimTagGroupFolderNode aimTagGroupFolderNode = new AimTagGroupFolderNode(project);
// aimTagGroupFolderNode.AddTo(projectNode);
//
// SecurityNode securityNode = new SecurityNode(project);
// securityNode.AddTo(projectNode);
//DriverFolderNode driverFolderNode = new DriverFolderNode(project);
//driverFolderNode.AddTo(projectNode);
motherNode.TreeView.MouseDoubleClick += new MouseEventHandler(TreeView_MouseDoubleClick);
return projectNode;
}
示例3: Init
/// <summary>
/// 初始化(获取mongodb信息)
/// </summary>
public void Init()
{
this.treeView1.Nodes.Clear();
connectionString = this.textBox_MongoUrl.Text;
service = new MongoService(new MongoConnectionString(connectionString));
//所有数据库
var listDatabase = service.client.ListDatabases().ToList();
foreach(BsonDocument dbDoc in listDatabase)
{
var dbName = dbDoc["name"].ToString();
TreeNode dbNode = new TreeNode(dbName, 0, 0);
dbNode.Tag = "database";
var db = service.client.GetDatabase(dbName);
//所有集合(可以理解为表)
var listCollection = db.ListCollections().ToList();
foreach (BsonDocument collDoc in listCollection)
{
var collName = collDoc["name"].ToString();
TreeNode collNode = new TreeNode(collName,1,1);
collNode.Tag = "collection";
dbNode.Nodes.Add(collNode);
}
this.treeView1.Nodes.Add(dbNode);
}
}
示例4: agregarNodo
private void agregarNodo(XmlNode inXmlNode, TreeNode inTreeNode)
{
XmlNode xNode;
TreeNode tNode;
XmlNodeList nodeList;
int i;
// Loop through the XML nodes until the leaf is reached.
// Add the nodes to the TreeView during the looping process.
if (inXmlNode.HasChildNodes)
{
nodeList = inXmlNode.ChildNodes;
for (i = 0; i <= nodeList.Count - 1; i++)
{
xNode = inXmlNode.ChildNodes[i];
inTreeNode.Nodes.Add(xNode.Attributes["Nombre"].Value);
tNode = inTreeNode.Nodes[i];
agregarNodo(xNode, tNode);
}
}
else
{
// Here you need to pull the data from the XmlNode based on the
// type of node, whether attribute values are required, and so forth.
inTreeNode.Text = inXmlNode.Attributes["Nombre"].Value;
}
}
示例5: initTrvTree
public void initTrvTree(TreeNodeCollection treeNodes, string strParentIndex, DataView dvList)
{
try
{
TreeNode tempNode;
DataView dvList1;
string currentNum;
dvList1 = dvList;
// select the datarow that it's parentcode is strParentIndex
DataRow[] dataRows = dvList.Table.Select("parentCode ='" + strParentIndex + "'");
foreach (DataRow dr in dataRows)
{
tempNode = new TreeNode();
tempNode.Text = dr["bookTypeCode"].ToString() + "-"
+ dr["bookTypeName"].ToString();
// tag property is save data about this treenode
tempNode.Tag = new treeNodeData(dr["bookTypeCode"].ToString(),
dr["bookTypeName"].ToString(), dr["bookTypeExplain"].ToString(),
dr["currentCode"].ToString(), dr["parentCode"].ToString());
currentNum = dr["currentCode"].ToString();
treeNodes.Add(tempNode);
// call rucursive
TreeNodeCollection temp_nodes = treeNodes[treeNodes.Count - 1].Nodes;
initTrvTree(temp_nodes, currentNum, dvList1);
}
}
catch (Exception)
{
MessageBox.Show("初始化TreeView失败");
}
}
示例6: CreatPropertiesTree
private void CreatPropertiesTree()
{
DataTable dtproperty = CommonFuncCall.GetDictionariesByDic_codes("sys_enterprise_property");
TreeNode tmpNd;
if (dtproperty != null)
{
foreach (DataRow drv in dtproperty.Rows)
{
tmpNd = new TreeNode();
tmpNd.Tag = drv;
tmpNd.Text = drv["dic_name"].ToString(); //name
//tmpNd.Name = drv["dic_id"].ToString();//id
tmpNd.Name = string.Empty;//id
this.tvNature.Nodes.Add(tmpNd);
}
}
ArrayList dic_name = new ArrayList();
dic_name.Add("sys_enterprise_property");
dtproperty = CommonFuncCall.GetDictionariesByPDic_codes(dic_name);
if (dtproperty != null)
{
foreach (DataRow drv in dtproperty.Rows)
{
tmpNd = new TreeNode();
tmpNd.Tag = drv;
tmpNd.Text = drv["dic_name"].ToString(); //name
tmpNd.Name = drv["dic_id"].ToString();//id
this.tvNature.Nodes[0].Nodes.Add(tmpNd);
}
}
this.tvNature.Nodes[0].Expand();
}
示例7: GetTree
public static TreeNode[] GetTree(this Ast ast)
{
var index = new Dictionary<Ast, TreeNode>();
var tree = new List<TreeNode>();
foreach (var ast1 in ast.FindAll(_ => true, true).ToList())
{
var node = new TreeNode(ast1.GetType().ToString().Split('.').Last());
node.ToolTipText = ast1.Extent.Text;
index.Add(ast1, node);
TreeNode parent;
if (ast1.Parent != null && index.TryGetValue(ast1.Parent, out parent))
{
parent.Nodes.Add(node);
}
else
{
tree.Add(node);
}
}
return tree.ToArray();
}
示例8: DisplayExceptionDetails
private void DisplayExceptionDetails(TreeNode node)
{
var exception = _exceptionDetailsList[node];
exceptionDetailsListView.SuspendLayout();
exceptionDetailsListView.Items.Clear();
if (exception.Type != null) exceptionDetailsListView.Items.Add("Exception").SubItems.Add(exception.Type);
if (exception.Message != null) exceptionDetailsListView.Items.Add("Message").SubItems.Add(exception.Message);
if (exception.TargetSite != null) exceptionDetailsListView.Items.Add("Target Site").SubItems.Add(exception.TargetSite);
if (exception.InnerException != null) exceptionDetailsListView.Items.Add("Inner Exception").SubItems.Add(exception.InnerException.Type);
if (exception.Source != null) exceptionDetailsListView.Items.Add("Source").SubItems.Add(exception.Source);
if (exception.HelpLink != null) exceptionDetailsListView.Items.Add("Help Link").SubItems.Add(exception.HelpLink);
if (exception.StackTrace != null) exceptionDetailsListView.Items.Add("Stack Trace").SubItems.Add(exception.StackTrace);
if (exception.Data != null)
{
foreach (var pair in exception.Data)
{
exceptionDetailsListView.Items.Add(string.Format("Data[\"{0}\"]", pair.Key)).SubItems.Add(pair.Value.ToString());
}
}
if (exception.ExtendedInformation != null)
{
foreach (var info in exception.ExtendedInformation)
{
var item = exceptionDetailsListView.Items.Add(info.Key);
item.UseItemStyleForSubItems = false;
item.Font = new Font(Font, FontStyle.Bold);
item.SubItems.Add(info.Value.ToString());
}
}
exceptionDetailsListView.ResumeLayout();
}
示例9: 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();
}
}
示例10: BindTags
private void BindTags()
{
cbTagCategory.DisplayMember = "Name";
cbTagCategory.ValueMember = "ID";
cbTagCategory.DataSource = TagCategories;
tvTags.Nodes.Clear();
foreach (var tc in TagCategories)
{
var catNode = new TreeNode();
catNode.Text = tc.Name;
foreach (var t in Tags.Where(w => w.TagCategoryID == tc.ID))
{
var tNode = new TreeNode();
tNode.Text = t.Name;
tNode.Tag = t;
tNode.Checked = SelectedTags.Exists(w => w.ID == t.ID);
catNode.Nodes.Add(tNode);
}
tvTags.Nodes.Add(catNode);
}
tvTags.ExpandAll();
}
示例11: MULT
public MULT(RARC.FileEntry FE, ref int SrcOffset, TreeNode ParentNode, System.Drawing.Color Color = default(System.Drawing.Color))
{
ParentFile = FE;
byte[] SrcData = ParentFile.GetFileData();
Offset = SrcOffset;
_Translation = new Vector2(
Helpers.ConvertIEEE754Float(Helpers.Read32(SrcData, SrcOffset)),
Helpers.ConvertIEEE754Float(Helpers.Read32(SrcData, SrcOffset + 0x04)));
_Rotation = ((short)(Helpers.Read16(SrcData, SrcOffset + 0x08)) / 182.04444444444444f).Clamp(-180, 179);
_RoomNumber = SrcData[SrcOffset + 0x0A];
_Unknown2 = SrcData[SrcOffset + 0x0B];
SrcOffset += 0x0C;
RenderColor = Color;
Node = Helpers.CreateTreeNode(string.Format("{0:X6}: {1}", Offset, new Vector2(_Translation.X / 100000, _Translation.Y / 100000)), this, string.Format("{0}", _Translation));
ParentNode.BackColor = RenderColor;
ParentNode.Nodes.Add(Node);
GLID = GL.GenLists(1);
GL.NewList(GLID, ListMode.Compile);
Helpers.DrawFramedCube(new Vector3d(15, 15, 15));
GL.EndList();
}
示例12: TableViewForm
public TableViewForm(TreeNode analysisViewNode)
{
InitializeComponent();
mAnalysisViewNode = analysisViewNode;
mTask = ((TaskModel)analysisViewNode.Parent.Parent.Tag).mTask;
}
示例13: RootNode
//private int len = 2;
public void RootNode(TreeNode pNode)
{
if (ds == null)
return;
DataView dvTree = new DataView(ds.Tables[0]);
//dvTree.RowFilter = "len(Code)=" + len.ToString();
dvTree.RowFilter = "Parent_Code=0";//Rank=1";
foreach (DataRowView Row in dvTree)
{
TreeNode Node = this.Nodes.Add(Row["Code"].ToString(), "[" + Row["Code"].ToString() + "]" + Row["Name"].ToString(), 1);
//AddNode(Node, len);
AddNode(Node);
}
this.ExpandAll();
if (m_SelectName.Trim() == "")
return;
foreach (TreeNode nt in this.Nodes)
{
if (nt.Name == SelectStringByLen(2))
{
this.SelectedNode = nt;
if (m_SelectName.Length > 2)
Select(nt);
return;
}
}
}
示例14: testPointView_AfterSelect
private void testPointView_AfterSelect(object sender, TreeViewEventArgs e)
{
TreeNode tmpNode;
ItemObject tmpObj;
List<ItemObject> stack;
if (e.Node == Root) return; //根节点返回
ItemObject itm = e.Node.Tag as ItemObject;
listProperty(itm);
#region 显示当前的item
stack = new List<ItemObject>(10);
tmpNode = e.Node;
stack.Add(tmpNode.Tag as ItemObject);
while ((tmpNode.Tag as ItemObject).type != PptType.Slide)
{
tmpNode = tmpNode.Parent;
stack.Add(tmpNode.Tag as ItemObject);
}
while (stack.Count > 0)
{
try
{
tmpObj = stack[stack.Count - 1];
showSomething(tmpObj);
stack.RemoveAt(stack.Count - 1);
}
catch
{
throw;
}
}
#endregion
}
示例15: FormQueryName
public FormQueryName(int userId, TreeView treeView, TreeNode folderNode)
{
InitializeComponent();
_connectionID = userId;
_original = treeView;
CurrentFolderNode = folderNode;
}