本文整理汇总了C#中System.Windows.Forms.TreeNode.add_Node方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.add_Node方法的具体用法?C# TreeNode.add_Node怎么用?C# TreeNode.add_Node使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNode
的用法示例。
在下文中一共展示了TreeNode.add_Node方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadFolder
public ascx_FolderView loadFolder(TreeNode treeNode, string path)
{
"Loading Folder: {0}".info(path);
if (path.valid())
{
FolderView.beginUpdate();
path = Environment.ExpandEnvironmentVariables(path); // in case there are Environment variables like %SystemDrive%
//"There are {0} files {0}".info(path.files().size());
//"There are {0} folders {0}".info(path.folder.folders().size());
var folders = path.folders().sort();
foreach(var folder in folders)
treeNode.add_Node(folder.fileName(), folder, folder.files().size() >0 || folder.folders().size()>0)
.color(Color.DarkOrange);
var files = path.files();
treeNode.add_Nodes(files, (file)=> file.fileName(), (file)=>file, (file)=>false,(file)=>Color.DarkBlue);
FolderView.endUpdate();
}
return this;
}
示例2: addObjectPropertyAndFields_Thread
public void addObjectPropertyAndFields_Thread(TreeNode targetNode, object targetObject)
{
if (targetObject is String) // skip strings
return;
if (targetObject is IDictionary)
{
var dictionary = (IDictionary)targetObject;
var index = 0;
foreach (var key in dictionary.Keys)
{
if (key is String)
targetNode.add_Node(key.str(), dictionary[key]);
else
{
index++;
var value = dictionary[key];
targetNode.add_Node("key_{0}: {1}".format(index, key.str()), key);
targetNode.add_Node("value_{0}: {1}".format(index, value.str()), value);
}
}
targetNode.expand();
}
else
if (targetObject is IEnumerable)
{
try
{
foreach (var item in (targetObject as IEnumerable))
targetNode.add_Node(item);
targetNode.expand();
}
catch (Exception ex)
{
ex.log("in addObjectPropertyAndFields IEnumerable loop");
}
}
else
{
if (SimpleView)
{
foreach (var property in targetObject.type().properties())
{
var propertyValue = PublicDI.reflection.getProperty(property, targetObject);
var newNode = targetNode.add_Node(property.Name, propertyValue, false);
switch (property.PropertyType.FullName)
{
case "System.String":
case "System.String[]":
case "System.Boolean":
case "System.DateTime":
case "System.Int32":
case "System.Int32[]":
case "System.Byte":
case "System.Int64":
newNode.color(Color.Gray);
break;
default:
if (propertyValue.isNull())
{
if (CreateObjectWhenNull)
{
propertyValue = property.PropertyType.ctor();
if (propertyValue.notNull())
{
"CREATE object for type: {0}".debug(propertyValue.type());
PublicDI.reflection.setProperty(property, targetObject, propertyValue);
WinForms_ExtensionMethods_TreeView.set_Tag(newNode, propertyValue);
}
else
"Could not create instance of type: {0}".error(propertyValue.type());
}
}
break;
}
}
}
else
{
//var objectNode = targetNode.add_Node(targetObject.str(), targetObject);
targetNode.add_Node("properties", null).add_Nodes(targetObject.type().properties(),
(item) => item.Name,
(item) => PublicDI.reflection.getProperty(item, targetObject),
(item) => false);
targetNode.add_Node("fields", null).add_Nodes(targetObject.type().fieldInfos(),
(item) => item.Name,
(item) => targetObject.field(item.Name), //PublicDI.reflection.getField(item,_object),
(item) => false);
targetNode.set_Text("{0} ({1} properties {2} fields)"
.format(targetNode.get_Text(),
targetNode.nodes()[1].nodes().size(),
targetNode.nodes()[0].nodes().size()));
}
}
if (ShowPropertyAndFieldInfo)
{
targetNode.add_Node("_PropertyInfo(s)", null).add_Nodes(targetObject.type().properties(),
(item) => item.Name);
//.........这里部分代码省略.........