当前位置: 首页>>代码示例>>C#>>正文


C# TreeView.EndUpdate方法代码示例

本文整理汇总了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();
            }
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:65,代码来源:GeneralClasses.cs

示例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;
            }
开发者ID:okyereadugyamfi,项目名称:softlogik,代码行数:39,代码来源:SecurityManager.cs

示例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();
            }
        }
开发者ID:blacklensama,项目名称:earthquake-project-ui,代码行数:72,代码来源:GeneralClasses.cs


注:本文中的TreeView.EndUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。