本文整理汇总了C#中System.Windows.Forms.TreeNode.Collapse方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.Collapse方法的具体用法?C# TreeNode.Collapse怎么用?C# TreeNode.Collapse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.TreeNode
的用法示例。
在下文中一共展示了TreeNode.Collapse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetNodeStyle
private static void SetNodeStyle(TreeNode Node)
{
int nNodeCount = 0;
if (Node.Nodes.Count != 0)
{
foreach (TreeNode tnTemp in Node.Nodes)
{
if (tnTemp.Checked == true)
nNodeCount++;
}
if (nNodeCount == Node.Nodes.Count)
{
Node.Checked = true;
Node.ExpandAll();
Node.ForeColor = Color.Black;
}
else if (nNodeCount == 0)
{
Node.Checked = false;
Node.Collapse();
Node.ForeColor = Color.Black;
}
else
{
Node.Checked = true;
Node.ForeColor = Color.Gray;
}
}
//当前节点选择完后,判断父节点的状态,调用此方法递归。
if (Node.Parent != null)
SetNodeStyle(Node.Parent);
}
示例2: RenderLevel
private void RenderLevel(XmlNode xmlNode)
{
TreeNode newTreeNode;
newTreeNode = new TreeNode(this.GetText(xmlNode));
if (this.SelectedNode == null)
{
this.Nodes.Add(newTreeNode);
}
else
{
this.SelectedNode.Nodes.Add(newTreeNode);
}
foreach (XmlNode childXmlNode in xmlNode)
{
if (!(childXmlNode is XmlWhitespace))
{
this.SelectedNode = newTreeNode;
this.RenderLevel(childXmlNode);
if (childXmlNode is XmlText)
{
newTreeNode.Collapse();
}
else
{
newTreeNode.Expand();
}
}
}
}
示例3: AddLazyNode
public void AddLazyNode(TreeNode parent, TreeNode node)
{
node.Nodes.Add(GetLoadingNode());
if (parent == null)
Nodes.Add(node);
else
parent.Nodes.Add(node);
node.Collapse();
}
示例4: Attach
public override void Attach(TreeNode myNode)
{
myNode.Tag = this;
myNode.SelectedImageKey = myNode.ImageKey = "BlockWeb";
myNode.Text = myWeb.Id + " @ " + myWeb.Address;
addTempNode(myNode);
myNode.Collapse();
myNodes.Add(myNode);
}
示例5: Populate
private void Populate(AssemblySet set)
{
_nodesTreeView.Nodes.Clear();
foreach (var asm in set)
{
var node = new TreeNode(asm.Name);
node.Tag = asm.Load();
node.Nodes.Add(new TreeNode()); // Placeholder node for async expanding.
node.Collapse();
_nodesTreeView.Nodes.Add(node);
}
}
示例6: addNode
private void addNode(TreeNode parent, string name, object val)
{
string strVal = val == null ? "null" : val.ToString();
if (strVal.Length > 20) strVal = strVal.Substring(0, 20) + "...";
TreeNode node = new TreeNode(name + " (" + strVal + ")");
if (val != null && val.GetType() != typeof(string) && !val.GetType().IsValueType)
{
node.Nodes.Add("ready-to-be-expanded-kafası");
node.Collapse();
node.Tag = val;
}
if (parent == null)
tree.Nodes.Add(node);
else
parent.Nodes.Add(node);
}
示例7: FillChild
public int FillChild(TreeNode parent, string ID)
{
DataSet ds = PDataset("SELECT * FROM world.tree WHERE ParentID = " + ID);
if (ds.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
TreeNode child = new TreeNode();
child.Text = dr["Name"].ToString().Trim();
string temp = dr["ID"].ToString();
child.Collapse();
parent.Nodes.Add(child);
FillChild(child, temp);
}
return 0;
}
else
{
return 0;
}
}
示例8: CheckNode
private void CheckNode(TreeNode node, bool check)
{
if (0 < node.Nodes.Count)
{
if (node.Checked)
{
node.Expand();
}
else
{
node.Collapse();
}
foreach (TreeNode t in node.Nodes)
{
t.Checked = check;
CheckNode(t, check);
}
}
}
示例9: ReExpandNodeUp
private void ReExpandNodeUp(TreeNode treeNode)
{
if (treeNode != null)
{
if (treeNode.IsExpanded)
{
treeNode.Collapse();
treeNode.Expand();
SelectedNode = treeNode;
OnAfterSelect(new TreeViewEventArgs(SelectedNode));
}
else
{
ReExpandNodeUp(treeNode.Parent);
}
}
}
示例10: SelectNode
//.........这里部分代码省略.........
{
if(IsSelectNodeRegExSatisfied(tn.Text))
{
ClearSelBranch(tnRoot);
if(!IsTreeNodeSelected(tn))
{
this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents);
}
TreeNode tnTemp = tn;
while(tnTemp.Parent != null)
{
if(!IsTreeNodeSelected(tnTemp.Parent))
{
this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents);
}
tnTemp = tnTemp.Parent;
}
}
break;
}
}
}
else
{
if(!IsTreeNodeSelected(tn) && IsSelectNodeRegExSatisfied(tn.Text))
{
ClearSelNodes(bTriggerSelNodesAddRemoveEvents);
if(this.SelNodes == null)
{
this.SelNodes = new Hashtable();
}
if(!IsTreeNodeSelected(tn))
{
this.SelNodesAdd(tn, bTriggerSelNodesAddRemoveEvents);
}
TreeNode tnTemp = tn;
while(tnTemp.Parent != null)
{
if(!IsTreeNodeSelected(tnTemp.Parent))
{
this.SelNodesAdd(tnTemp.Parent, bTriggerSelNodesAddRemoveEvents);
}
tnTemp = tnTemp.Parent;
}
}
}
if(bChangeSelNode)
{
ChangeSelNode(tn, bTriggerSelNodeEvents);
}
break;
default:
//Execution should never end up here!
break;
}
#endregion Switch-statement
if(this.SelNode == tn)
{
bRetVal = true;
}
if(bChangeSelNode && tn != null)
{
if(tn.IsExpanded && this.CollapseTreeNodeOnSelect)
{
tn.Collapse();
}
else if(this.ExpandTreeNodeOnSelect)
{
tn.Expand();
}
}
if(!this.Enabled)
{
//DisableNodes() could be called, but the call to DisableNode(tn) should work.
//DisableNodes();
DisableNode(tn);
}
else if(!bActive)
{
DeactivateSelNode(tn);
}
}
return bRetVal;
}
示例11: doDisplay
/// <summary>
/// Affichage du TreeView Final
/// </summary>
public void doDisplay()
{
Log.Info("Affichage de l'arborescence finale");
string txtAbsent = "";
treeView.Nodes.Clear();
lblNbFiles.Text = _nbcopiedFiles.ToString("D5");
lblNbTotal.Text = _nbTotalFiles.ToString("D5");
string pathRoot = p_applClass.RootDir;
TreeNode nodSchool = treeView.Nodes.Add(pathRoot);
/// On fait un affichage du LAB complet (c'est à dire tout le brut)
TreeNode nodLab = new TreeNode(p_applClass.Param.ExportDirectory);
int _cptPhoto = 0;
// On balaye les classes classiques
for (int _indClass = 0; _indClass < p_nbClass; _indClass++)
{
string _className = p_applClass.School.ListClass[_indClass].nameClass;
int _idClass = p_applClass.School.ListClass[_indClass].idClass;
_cptPhoto = 0;
string _absent = this.getNbAbsents(_idClass.ToString() + Constantes.cstIndividu);
txtAbsent += "Classe : " + _className + _absent + Environment.NewLine;
foreach (string _eleveAbsent in this.getListAbsents(_idClass.ToString() + Constantes.cstIndividu)) { txtAbsent += "-->" + _eleveAbsent + Environment.NewLine; }
// On crée le noeud correspondant à la classe
TreeNode nodClass = new TreeNode(_className);
// On charge le répertoire contenant les images INDIV
string _dirIndiv = pathRoot + "\\" + p_applClass.Param.ExportDirectory + "\\" + _className + "\\" + p_applClass.Param.IndivDirectory;
TreeNode nodIndiv = new TreeNode(p_applClass.Param.IndivDirectory + _absent);
_cptPhoto += this.countFile(_dirIndiv, nodIndiv); // On compte les fichiers dans le répertoire
nodClass.Nodes.Add(nodIndiv);
// On charge le répertoire contenant les images GROUPES
string _dirGroup = pathRoot + "\\" + p_applClass.Param.ExportDirectory + "\\" + _className + "\\" + p_applClass.Param.GroupDirectory;
TreeNode nodGroup = new TreeNode(p_applClass.Param.GroupDirectory);
_cptPhoto += this.countFile(_dirGroup, nodGroup); // On compte les fichiers dans le répertoire
nodClass.Nodes.Add(nodGroup);
nodLab.Nodes.Add(nodClass);
if (_cptPhoto == 0) { nodClass.Collapse(); } else { nodClass.ExpandAll(); }
System.Threading.Thread.Sleep(100);
txtAbsent += Environment.NewLine;
}
_cptPhoto = 0;
// On traite la classe FRATRIE
// On crée le noeud correspondant à la classe
TreeNode nodFratrie = new TreeNode("Fratries");
// On charge le répertoire contenant les images GROUP
string _dirFratIndiv = pathRoot + "\\" + p_applClass.Param.ExportDirectory + "\\" + Constantes.cstFratrie + "\\" + p_applClass.Param.IndivDirectory;
_cptPhoto += this.countFile(_dirFratIndiv, nodFratrie); // On compte les fichiers dans le répertoire
if (_cptPhoto == 0) { nodFratrie.Collapse(); } else { nodFratrie.ExpandAll(); }
nodLab.Nodes.Add(nodFratrie);
nodLab.Expand();
nodSchool.Nodes.Add(nodLab);
/// On parcours la sélection du photographe
TreeNode nodSelection = new TreeNode(p_applClass.Param.SelectDirectory);
int _cptSelectPhoto = 0;
// On balaye les classes classiques
for (int _indClass = 0; _indClass < p_nbClass; _indClass++)
{
string _className = p_applClass.School.ListClass[_indClass].nameClass;
int _idClass = p_applClass.School.ListClass[_indClass].idClass;
_cptSelectPhoto = 0;
// On crée le noeud correspondant à la classe
TreeNode nodClass = new TreeNode(_className);
// On charge le répertoire contenant les images INDIV
string _dirIndiv = pathRoot + "\\" + p_applClass.Param.SelectDirectory + "\\" + p_applClass.Param.IndivDirectory + "\\" + _className;
TreeNode nodIndiv = new TreeNode(p_applClass.Param.IndivDirectory);
_cptSelectPhoto += this.countFile(_dirIndiv, nodIndiv); // On compte les fichiers dans le répertoire
nodClass.Nodes.Add(nodIndiv);
// On charge le répertoire contenant les images GROUPES
string _dirGroup = pathRoot + "\\" + p_applClass.Param.SelectDirectory + "\\" + p_applClass.Param.GroupDirectory + "\\" + _className;
TreeNode nodGroup = new TreeNode(p_applClass.Param.GroupDirectory);
_cptSelectPhoto += this.countFile(_dirGroup, nodGroup); // On compte les fichiers dans le répertoire
nodClass.Nodes.Add(nodGroup);
nodSelection.Nodes.Add(nodClass);
if (_cptSelectPhoto == 0) { nodClass.Collapse(); } else { nodClass.ExpandAll(); }
System.Threading.Thread.Sleep(100);
}
_cptSelectPhoto = 0;
// On traite la classe FRATRIE
// On crée le noeud correspondant à la classe
TreeNode nodSelectFratrie = new TreeNode(Constantes.cstFratrie);
// On charge le répertoire contenant les images INDIV
string _dirSelectFratIndiv = pathRoot + "\\" + p_applClass.Param.SelectDirectory + "\\" + p_applClass.Param.IndivDirectory + "\\" + Constantes.cstFratrie;
_cptSelectPhoto += this.countFile(_dirSelectFratIndiv, nodSelectFratrie); // On compte les fichiers dans le répertoire
//.........这里部分代码省略.........
示例12: CollapseAll
private void CollapseAll(TreeNode node)
{
if (node == null) return;
node.Collapse();
foreach (TreeNode n in node.Nodes) {CollapseAll(n);}
}
示例13: SourceTree
public SourceTree()
{
InitializeComponent();
_dics.Add(TreeNodeType.TABLE, "表");
_dics.Add(TreeNodeType.TRIGGER, "触发器");
_dics.Add(TreeNodeType.SEQUENCE, "序列");
_dics.Add(TreeNodeType.FUNCTION, "函数");
_dics.Add(TreeNodeType.PROCEDURE, "存储过程");
_dics.Add(TreeNodeType.JAVASOURCE, "Java资源");
_dics.Add(TreeNodeType.JOB, "事务");
_dics.Add(TreeNodeType.VIEW, "视图");
foreach (var item in _dics)
{
TreeNode node = new TreeNode(item.Value);
node.Tag = item.Key;
node.ToolTipText = "点击后加载";
this.tvSourceTree.Nodes.Add(node);
node.Collapse();
}
//this.tvSourceTree.ExpandAll();
}
示例14: SetupSceneTree
private void SetupSceneTree()
{
treeScene.Nodes.Clear();//clear the old
TreeNode scenenode = new TreeNode("Scene");
treeScene.Nodes.Add(scenenode);
TreeNode selNode = null;
foreach (Object3d obj in UVDLPApp.Instance().Engine3D.m_objects)
{
if(obj.tag == Object3d.OBJ_NORMAL)
{
TreeNode objnode = new TreeNode(obj.Name);
objnode.Tag = obj;
scenenode.Nodes.Add(objnode);
if (obj == UVDLPApp.Instance().SelectedObject) // expand this node
{
//objnode.BackColor = Color.LightBlue;
//treeScene.SelectedNode = objnode;
selNode = objnode;
}
if (obj.m_supports.Count > 0) //if object has supports, create a node for them
{
TreeNode supnode = new TreeNode("Supports");
objnode.Nodes.Add(supnode);
supnode.Collapse();
foreach (Object3d sup in obj.m_supports)
{
TreeNode tn = new TreeNode(sup.Name);
tn.Tag = sup;
supnode.Nodes.Add(tn);
}
}
}
}
if (selNode != null)
selNode.BackColor = Color.Green;
scenenode.Expand();
treeScene.SelectedNode = selNode;
}
示例15: Fill
//.........这里部分代码省略.........
bool restoreLoading = IsLoading(node);
try
{
string start_path = GetNodePath(node);
{
DirItemLoader loader = new DirItemLoader(channel,
null,
start_path,
"",
this.Lang);
children.Clear();
foreach (ResInfoItem item in loader)
{
TreeNode nodeNew = new TreeNode(item.Name, item.Type, item.Type);
nodeNew.Tag = item;
if (item.HasChildren)
SetLoading(nodeNew);
if (EnabledIndices != null
&& StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false)
nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor);
if (HideIndices != null
&& StringUtil.IsInList(nodeNew.ImageIndex, HideIndices) == true)
continue;
children.Add(nodeNew);
}
}
// 在根级追加 '!' 下的 dp2library 本地文件或目录
if (string.IsNullOrEmpty(start_path))
{
ResInfoItem item = new ResInfoItem();
item.Name = "!";
item.Type = 4;
item.HasChildren = true;
TreeNode nodeNew = new TreeNode(item.Name, item.Type, item.Type);
nodeNew.Tag = item;
if (item.HasChildren)
SetLoading(nodeNew);
if (EnabledIndices != null
&& StringUtil.IsInList(nodeNew.ImageIndex, EnabledIndices) == false)
nodeNew.ForeColor = ControlPaint.LightLight(nodeNew.ForeColor);
if (HideIndices != null
&& StringUtil.IsInList(nodeNew.ImageIndex, HideIndices) == true)
{
}
else
children.Add(nodeNew);
}
restoreLoading = false; // 防止 finally 复原
return 0;
}
catch(ChannelException ex)
{
strError = ex.Message;
return -1;
#if NO
if (ex.ErrorCode == ErrorCode.AccessDenied)
{
strError = ex.Message;
return -1;
}
strError = "Fill() 过程出现异常: " + ExceptionUtil.GetExceptionText(ex);
return -1;
#endif
}
catch (Exception ex)
{
strError = "Fill() 过程出现异常: " + ExceptionUtil.GetExceptionText(ex);
return -1;
}
finally
{
if (channel_param == null)
{
channel.Timeout = old_timeout;
this.CallReturnChannel(channel, true);
}
if (restoreLoading)
{
SetLoading(node);
if (node != null)
node.Collapse();
}
}
}