Example #1
0
        public void AddNode(TreeNode parent, ITGVNode child)
        {
            TreeNode newNode = null;

            if (parent == null)
            {
                newNode     = tgvTreeView.Nodes.Add(child.ITGV_UniqueName, child.ITGV_Name, child.ITGV_Type, child.ITGV_Type);
                newNode.Tag = child;
                Rows.Add(child);
            }
            else
            {
                newNode     = parent.Nodes.Add(child.ITGV_UniqueName, child.ITGV_Name, child.ITGV_Type, child.ITGV_Type);
                newNode.Tag = child;

                int index = Rows.IndexOf(parent.Tag as ITGVNode);
                if (index != -1)
                {
                    Rows.Insert(index + parent.Nodes.Count, child);
                }
                else
                {
                    MessageBox.Show("Error getting " + parent.Text + " index in rows !");
                }
            }

            List <string> fields = child.ITGV_GetFields();

            foreach (string field in fields)
            {
                if (!Columns.Contains(field))
                {
                    Columns.Add(field);
                }
            }

            newNodes.Add(newNode);

            if (child.ITGV_HasChildren())
            {
                newNode.Nodes.Add(FAKENODENAME);
            }
        }
Example #2
0
        private void tgvTreeView_BeforeCollapse(object sender, TreeViewCancelEventArgs e)
        {
            OldScroll = vScroller.Value;

            if (!MuteEvents)
            {
                TreeNode ExNode      = e.Node;
                bool     expandAsked = false;
                if (!ExpandAll && ModifierKeys == Keys.Shift)
                {
                    expandAsked = true;
                    ExpandAll   = true;
                }

                foreach (TreeNode node in ExNode.Nodes)
                {
                    ITGVNode tgvNode = node.Tag as ITGVNode;

                    Rows.Remove(tgvNode);

                    if (ExpandAll)
                    {
                        node.Collapse();
                    }
                    else
                    {
                        RemoveRows(node);
                    }
                }

                ExNode.Nodes.Clear();
                ExNode.Nodes.Add(FAKENODENAME);

                if (expandAsked)
                {
                    ExpandAll = false;
                }
            }
        }