Example #1
0
        // expand row
        public bool ExpandRow(int row)
        {
            // sanity
            if (row < Rows.Fixed || row >= Rows.Count)
            {
                return(false);
            }

            // check that the row is not already expanded
            C1FlexDataTree childGrid = Rows[row].UserData as C1FlexDataTree;

            if (childGrid != null)
            {
                return(false);
            }

            // check that we have a data source for this row
            object dataSource = _colChild != null ? _colChild[row] : null;

            if (!(dataSource is IBindingList))
            {
                return(false);
            }

            // add node row (unbound) to display child
            Rows.InsertNode(row + 1, -1);

            // make new row non-editable (it's just a placeholder)
            Rows[row + 1].AllowEditing = false;

            // create child grid
            childGrid = new C1FlexDataTree();
            if (SuspendUpdates)
            {
                childGrid.SuspendUpdates = true;
            }
            childGrid.Visible    = false;
            childGrid.ScrollBars = ScrollBars.Horizontal;

            // attach child grid to parent, set data source
            Controls.Add(childGrid);
            childGrid.DataSource = dataSource;

            // save references:
            // child grid Tag property contains a reference to the parent row
            // parent row UserData contains a reference to the child grid
            childGrid.Tag      = Rows[row];
            Rows[row].UserData = childGrid;

            // move child grid into position, make it visible
            childGrid.UpdatePosition();
            childGrid.Visible = true;
            if (!SuspendUpdates)
            {
                childGrid.Focus();
            }

            // done
            return(true);
        }
Example #2
0
 // update size/position of all child grids and of this grid within this parent.
 // this is called when the grid scrolls, when it's size changes, and when
 // rows or columns are added, removed, or resized.
 private void UpdateChildren()
 {
     // update position of all children
     for (int row = 0; row < Rows.Count; row++)
     {
         C1FlexDataTree child = Rows[row].UserData as C1FlexDataTree;
         if (child != null)
         {
             child.SuspendUpdates = false;
             child.UpdatePosition();
         }
     }
 }