本文整理汇总了C#中TreeView.EndUpdate方法的典型用法代码示例。如果您正苦于以下问题:C# TreeView.EndUpdate方法的具体用法?C# TreeView.EndUpdate怎么用?C# TreeView.EndUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeView
的用法示例。
在下文中一共展示了TreeView.EndUpdate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadXmlFileInTreeView
public void LoadXmlFileInTreeView(TreeView treeView, string fileName)
{
XmlTextReader reader = null;
try
{
treeView.BeginUpdate();
reader = new XmlTextReader(fileName);
TreeNode n = new TreeNode(fileName);
treeView.Nodes.Add(n);
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
bool isEmptyElement = reader.IsEmptyElement;
StringBuilder text = new StringBuilder();
text.Append(reader.Name);
int attributeCount = reader.AttributeCount;
if (attributeCount > 0)
{
text.Append(" ( ");
for (int i = 0; i < attributeCount; i++)
{
if (i != 0) text.Append(", ");
reader.MoveToAttribute(i);
text.Append(reader.Name);
text.Append(" = ");
text.Append(reader.Value);
}
text.Append(" ) ");
}
if (isEmptyElement)
{
n.Nodes.Add(text.ToString());
}
else
{
n = n.Nodes.Add(text.ToString());
}
}
else if (reader.NodeType == XmlNodeType.EndElement)
{
n = n.Parent;
}
else if (reader.NodeType == XmlNodeType.XmlDeclaration)
{
}
else if (reader.NodeType == XmlNodeType.None)
{
return;
}
else if (reader.NodeType == XmlNodeType.Text)
{
n.Nodes.Add(reader.Value);
}
}
}
finally
{
treeView.EndUpdate();
reader.Close();
}
}
示例2: BuildSecurity
public static void BuildSecurity(TreeView SourceTree, dsUserSecurity SourceData, bool ClearTree)
{
dsUserSecurity.SPApplicationDataTable dvTreeTable;
TreeNode rootNode;
TreeNode applicationNode;
dvTreeTable = SourceData.SPApplication;
if (ClearTree == false) //Might be a root node
{
rootNode = SourceTree.Nodes[0];
}
else
{
SourceTree.Nodes.Clear();
//rootNode = SourceTree.Nodes.Add(TextDictionary("FL_SECURITY"))
rootNode = SourceTree.Nodes.Add("Security Explorer");
}
SourceTree.BeginUpdate();
foreach (dsUserSecurity.SPApplicationRow drvRow in dvTreeTable)
{
try
{
applicationNode = rootNode.Nodes.Add(drvRow("Name").ToString());
BuildRoleNode(applicationNode, drvRow);
applicationNode.Expand();
applicationNode.ImageKey = "ApplicationNode";
applicationNode.Tag = "A:" + drvRow("ApplicationID").ToString();
}
catch (Exception)
{
}
}
rootNode.Expand();
SourceTree.EndUpdate();
Cursor.Current = Cursors.Default;
}
示例3: DeserializeTreeView
public void DeserializeTreeView(TreeView treeView, string fileName)
{
XmlTextReader reader = null;
try
{
// disabling re-drawing of treeview till all nodes are added
treeView.BeginUpdate();
reader = new XmlTextReader(fileName);
TreeNode parentNode = null;
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element)
{
if (reader.Name == XmlNodeTag)
{
TreeNode newNode = new TreeNode();
bool isEmptyElement = reader.IsEmptyElement;
// loading node attributes
int attributeCount = reader.AttributeCount;
if (attributeCount > 0)
{
for (int i = 0; i < attributeCount; i++)
{
reader.MoveToAttribute(i);
SetAttributeValue(newNode, reader.Name, reader.Value);
}
}
// add new node to Parent Node or TreeView
if (parentNode != null)
parentNode.Nodes.Add(newNode);
else
treeView.Nodes.Add(newNode);
// making current node 'ParentNode' if its not empty
if (!isEmptyElement)
{
parentNode = newNode;
}
}
}
// moving up to in TreeView if end tag is encountered
else if (reader.NodeType == XmlNodeType.EndElement)
{
if (reader.Name == XmlNodeTag)
{
parentNode = parentNode.Parent;
}
}
else if (reader.NodeType == XmlNodeType.XmlDeclaration)
{ //Ignore Xml Declaration
}
else if (reader.NodeType == XmlNodeType.None)
{
return;
}
else if (reader.NodeType == XmlNodeType.Text)
{
parentNode.Nodes.Add(reader.Value);
}
}
}
finally
{
// enabling redrawing of treeview after all nodes are added
treeView.EndUpdate();
reader.Close();
}
}