protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
 {
     if (e.Location.X > this.InheritedStyle.Padding.Left)
     {
         base.OnMouseDown(e);
     }
     else
     {
         // Expand the node
         //TODO: Calculate more precise location
         TreeGridNode node = this.OwningNode;
         if (node != null)
         {
             node._grid._inExpandCollapseMouseCapture = true;
             if (node.IsExpanded)
             {
                 node.Collapse();
             }
             else
             {
                 node.Expand();
             }
         }
     }
 }
Exemple #2
0
 protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
 {
     if (e.Location.X > this.pad.Left || this.IsInEditMode)
     {
         on_name_click = true;
         base.OnMouseDown(e);
     }
     else
     {
         // Expand the node
         //TODO: Calculate more precise location
         TreeGridNode node = this.OwningNode;
         on_name_click = false;
         if (node != null && node._grid != null && node.HasChildren)
         {
             node._grid._inExpandCollapseMouseCapture = true;
             if (node.IsExpanded)
             {
                 node.Collapse();
             }
             else
             {
                 node.Expand();
             }
         }
     }
 }
Exemple #3
0
 protected override void OnMouseDown(DataGridViewCellMouseEventArgs e)
 {
     if (e.Location.X > this.GlyphMargin && e.Location.X < this.GlyphMargin + GLYPH_WIDTH)
     {
         TreeGridNode node = this.OwningNode;
         if (node != null)
         {
             node.Grid.inExpandCollapseMouseCapture = true;
             if (node.IsExpanded)
             {
                 node.Collapse();
             }
             else
             {
                 node.Expand();
             }
         }
     }
     else if (e.Location.X > this.GlyphMargin + GLYPH_WIDTH && e.Location.X < this.Style.Padding.Left - GLYPH_WIDTH)
     {
         // CheckBox
         this.OwningNode.IsCheckStateChangedByProgram = true;
         this.OwningNode.Checked = !this.OwningNode.Checked;
     }
     else
     {
         base.OnMouseDown(e);
     }
 }
Exemple #4
0
        public static void UpdateNodesForLocalList(TreeGridView tree, TreeGridNodeCollection collection, IList <IListItem> contents)
        {
            // Add or overwrite existing items
            for (int i = 0; i < contents.Count; i++)
            {
                if (i < collection.Count)
                {
                    // Overwrite
                    //if (!contents[i].IsLiteral)
                    ((TreeGridNode)collection[i]).Content = contents[i];
                }
                else
                {
                    // Add
                    //if (!contents[i].IsLiteral)
                    {
                        TreeGridNode tn = new TreeGridNode(tree, contents[i]);
                        tn.UserRow = false;
                        tn.Update();
                        collection.Add(tn);
                        tree.Rows.Add(tn);
                        if (contents[i] is ModuleItem)
                        {
                            tn.Expand();
                        }
                    }
                }
            }
            // Delete other nodes
            while (collection.Count > contents.Count)
            {
                collection.RemoveAt(collection.Count - 1);
                tree.Rows.RemoveAt(tree.Rows.Count - 1);
            }
            for (int i = 0; i < tree.Rows.Count; i++)
            {
                tree.InvalidateRow(i);
            }
            //tree.Update();
//            tree.UpdateSelection();
//            tree.FullUpdate();
        }