コード例 #1
0
        /// <summary>
        /// Using the Cell Button for Expand an collapse in NestedTable.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void gridGroupingControl1_TableControlCellButtonClicked(object sender, GridTableControlCellButtonClickedEventArgs e)
        {
            GridTableCellStyleInfo style = this.gridGroupingControl1.Table.GetTableCellStyle(e.Inner.RowIndex, e.Inner.ColIndex);

            if (style.TableCellIdentity == null)
            {
                return;
            }

            if (style.TableCellIdentity.TableCellType == GridTableCellType.RecordPlusMinusCell)
            {
                if (style.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.NestedTable)
                {
                    // NestedTable
                    GridNestedTable nt = (GridNestedTable)style.TableCellIdentity.DisplayElement;

                    foreach (Element el in nt.ChildTable.Elements)
                    {
                        if (el.Kind == DisplayElementKind.Record)
                        {
                            if (style.TableCellIdentity.RowIndex == this.gridGroupingControl1.Table.NestedDisplayElements.IndexOf(el))
                            {
                                Record r            = Record.GetParentRecord(el);
                                bool   shouldExpand = !r.IsExpanded;
                                this.gridGroupingControl1.Table.CurrentRecord = r;
                                r.IsExpanded   = shouldExpand;
                                e.Inner.Cancel = true;
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        private void gridGroupingControl1_TableControlCellButtonClicked(object sender, GridTableControlCellButtonClickedEventArgs e)
        {
            GridTableCellStyleInfo         style = (GridTableCellStyleInfo)e.TableControl.Model[e.Inner.RowIndex, e.Inner.ColIndex];
            GridTableCellStyleInfoIdentity id    = style.TableCellIdentity;

            if (id.TableCellType != GridTableCellType.NestedTableCell)
            {
                string column = (id.Column != null) ? id.Column.ToString() : "";
                string s      = "TableControlCellButtonClicked on " + id.TableCellType.ToString() + "(" + column + ", " + id.DisplayElement.GetType().Name + ")";

                Console.WriteLine(s);
                e.Inner.Cancel = true;
            }

            if (id.TableCellType == GridTableCellType.RecordPlusMinusCell)
            {
                // Expand record without moving current record to that record (change default behavior
                // of grid).
                Record r = id.DisplayElement.ParentRecord;
                r.IsExpanded   = !r.IsExpanded;
                e.Inner.Cancel = true;  // don't let grid handle CellButtonClicked - otherwise it would reverse the IsExpanded call.
            }
        }