Esempio n. 1
0
        /// <summary>
        /// Demonstrates different alternatives to get to the summary text (strong typed vs GridSummaryColumnDescriptor.Format)
        /// </summary>
        public string GetSummaryText(Group group, string summaryRowName, string summaryColumnName)
        {
            GridTable                   table = (GridTable)group.ParentTable;
            GridTableDescriptor         td    = table.TableDescriptor;
            GridSummaryRowDescriptor    srd   = td.SummaryRows[summaryRowName];
            GridSummaryColumnDescriptor scd   = srd.SummaryColumns[summaryColumnName];

            return(GetSummaryText(group, scd));
        }
Esempio n. 2
0
        /// <summary>
        /// Demonstrates different alternatives to get to the summary text (strong typed vs GridSummaryColumnDescriptor.Format)
        /// </summary>
        string GetSummaryText(Group group, GridSummaryColumnDescriptor scd)
        {
            GridTable           table = (GridTable)group.ParentTable;
            GridTableDescriptor td    = table.TableDescriptor;

            string summaryText = "";

            bool use31Code = true;

            if (use31Code)
            {
                if (scd != null)
                {
                    // Option 1: GetDisplayText - this is actually the code used when you simply would call
                    // e.Style.Text = ((GridTable) table).GetSummaryText(group, "SummaryRow 1", "FreightAverage");
                    //
                    // Text is formatted as defined in GridSummaryColumnDescriptor.Format
                    summaryText = scd.GetDisplayText(group);

                    // or Option 2: Strong typed access to DoubleAggregateSummary.
                    DoubleAggregateSummary summary1 = (DoubleAggregateSummary)group.GetSummary(scd.SummaryDescriptor);
                    summaryText = string.Format("{0:c}", summary1.Average);

                    // or Option 3: Use reflection to get "Average" property of summary
                    summaryText = string.Format("{0:c}", group.GetSummaryProperty(scd.SummaryDescriptor, "Average"));
                }
            }
            else
            {
                // This is the code you had to use in version 3.0 and earlier (still working but bit more complicate)
                if (scd != null)
                {
                    SummaryDescriptor sd1 = scd.SummaryDescriptor;
                    if (sd1 != null)
                    {
                        int indexOfSd1 = table.TableDescriptor.Summaries.IndexOf(sd1);

                        ISummary sum1  = group.GetSummaries(table)[indexOfSd1];
                        string   text1 = scd.GetDisplayText(sum1);
                        summaryText = text1;

                        // - or - (access value directly)
                        // strong typed - you have to cast to Int32AggregateSummary.

                        DoubleAggregateSummary summary1 = (DoubleAggregateSummary)group.GetSummaries(table)[indexOfSd1];
                        summaryText = string.Format("{0:c}", summary1.Average);
                    }
                }
            }

            return(summaryText);
        }
Esempio n. 3
0
        /// <summary>
        /// Applying WeightedSummary for Given Columns
        /// </summary>
        private GridSummaryColumnDescriptor GetWeightedSummaryColumnDescriptor(string sourceCol, string weightCol)
        {
            GridSummaryColumnDescriptor wgtSumCol = new GridSummaryColumnDescriptor();

            wgtSumCol.Name          = string.Format("{0}_{1}", sourceCol, weightCol); //special name following the convention above
            wgtSumCol.DataMember    = sourceCol;                                      //the column this summary is applied to
            wgtSumCol.DisplayColumn = sourceCol;                                      //where thissummary is displayed
            wgtSumCol.Format        = "{WeightedAverage:#.##}";                       //what is displayed in the summary
            wgtSumCol.SummaryType   = SummaryType.Custom;                             //marks this as a CustomSummary
            wgtSumCol.Appearance.AnySummaryCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            wgtSumCol.MaxLength = 6;

            return(wgtSumCol);
        }
Esempio n. 4
0
        /// <summary>
        /// Grouping sample Customizations.
        /// </summary>
        private void SampleCustomization()
        {
            //Set dataSource
            this.gridGroupingControl1.DataSource = this.dataSet11.Orders;

            // Adding Summaries
            GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor("Sum", SummaryType.DoubleAggregate, "Freight", "{Sum:#}");
            GridSummaryRowDescriptor    srd = new GridSummaryRowDescriptor("Sum", "$", scd);

            srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            srd.Appearance.AnyCell.BackColor           = Color.Cornsilk;
            this.gridGroupingControl1.GetTableDescriptor("Orders").SummaryRows.Add(srd);

            this.gridGroupingControl1.ShowGroupDropArea = true;
            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("RequiredDate");

            // Creating summaries in caption
            this.gridGroupingControl1.ChildGroupOptions.ShowCaptionSummaryCells = true;
            this.gridGroupingControl1.ChildGroupOptions.ShowSummaries           = false;
            this.gridGroupingControl1.ChildGroupOptions.CaptionSummaryRow       = "Sum";
            this.gridGroupingControl1.ChildGroupOptions.CaptionText             = "{RecordCount} Items";

            // Providing a good look and enabling CaptionSummaryCells as RecordFieldCells
            this.gridGroupingControl1.Appearance.GroupCaptionCell.BackColor   = this.gridGroupingControl1.Appearance.RecordFieldCell.BackColor;
            this.gridGroupingControl1.Appearance.GroupCaptionCell.Borders.Top = new GridBorder(GridBorderStyle.Standard);
            this.gridGroupingControl1.Appearance.GroupCaptionCell.CellType    = "Static";

            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                Regex  rex   = new Regex(@"\p{Lu}");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// WeightedSummary sample Customizations
        /// </summary>
        private void SampleCustomization()
        {
            this.label1.Text += "	Weighted sum of Col2 using weights from Col3";
            this.label2.Text += "	Weighted sum of Col4 using weights from Col5";

            //needed to setup the CustomSummary type
            this.gridGroupingControl1.TableDescriptor.QueryCustomSummary += new GridQueryCustomSummaryEventHandler(gridGroupingControl1_QueryCustomSummary);

            //use a code naming convention to pass the column holding the weights into the SummaryDescriptor

            //weighted sum of Col2 using weights from Col3
            GridSummaryColumnDescriptor wgtSumCol2 = GetWeightedSummaryColumnDescriptor("Col2", "Col3");

            //weighted sum of Col4 using weights from Col5
            GridSummaryColumnDescriptor wgtSumCol4 = GetWeightedSummaryColumnDescriptor("Col4", "Col5");

            //add the summary columns to a summary row
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row0", "Weighted Summary", new GridSummaryColumnDescriptor[] { wgtSumCol2, wgtSumCol4 }));
            this.gridGroupingControl1.TableDescriptor.Columns["Col0"].Width = 150;

            //group a column
            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("Col1");
            this.gridGroupingControl1.Table.ExpandAllGroups();

            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"\d+");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Grouping sample Customizations
        /// </summary>
        private void SampleCustomization()
        {
            //Add Grouped column
            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("ShipCountry", ListSortDirection.Descending);
            this.gridGroupingControl1.Table.TopLevelGroup.Groups[7].IsExpanded            = true;
            this.gridGroupingControl1.Table.TopLevelGroup.Groups[7].Records[5].IsExpanded = true;

            // Adding Summaries for the Details Table
            GridSummaryColumnDescriptor scd = new GridSummaryColumnDescriptor("Sum", SummaryType.DoubleAggregate, "Freight", "{Sum:#}");
            GridSummaryRowDescriptor    srd = new GridSummaryRowDescriptor("Sum", "$", scd);

            srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            srd.Appearance.AnyCell.BackColor           = Color.FromArgb(255, 231, 162);
            this.gridGroupingControl1.GetTableDescriptor("Orders").SummaryRows.Add(srd);

            // Adding Summaries for the Details Table
            scd = new GridSummaryColumnDescriptor("Sum", SummaryType.Int32Aggregate, "Quantity", "{Sum:#}");
            srd = new GridSummaryRowDescriptor("Sum", "Total", scd);
            srd.Appearance.AnyCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            srd.Appearance.AnyCell.BackColor           = Color.FromArgb(255, 231, 162);
            this.gridGroupingControl1.GetTableDescriptor("Order Details").SummaryRows.Add(srd);

            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                Regex  rex   = new Regex(@"\p{Lu}");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Required Method for sample level customization.
        /// </summary>
        void SampleCustomization()
        {
            GridTableDescriptor ordersDescriptor = this.gridGroupingControl1.TableDescriptor;
            // You can define a summary row and mark it hidden.
            // In that summary row you can add a column and set it's mapping name (and DisplayColumn) to be Freight

            GridSummaryColumnDescriptor summaryColumn1 = new GridSummaryColumnDescriptor("FreightAverage", SummaryType.DoubleAggregate, "Freight", "{Average:###.00}");
            GridSummaryRowDescriptor    summaryRow1    = new GridSummaryRowDescriptor();

            summaryRow1.Name    = "SummaryRow 1";
            summaryRow1.Visible = false;
            summaryRow1.SummaryColumns.Add(summaryColumn1);
            ordersDescriptor.SummaryRows.Add(summaryRow1);

            // This is a second row, not marked hidden and therefore shown at the end of the group.
            GridSummaryColumnDescriptor summaryColumn2 = new GridSummaryColumnDescriptor("FreightTotal", SummaryType.DoubleAggregate, "Freight", "{Sum:###.00}");
            GridSummaryRowDescriptor    summaryRow2    = new GridSummaryRowDescriptor();

            summaryRow2.Name    = "SummaryRow 2";
            summaryRow2.Title   = "Total";
            summaryRow2.Visible = true;
            summaryRow2.SummaryColumns.Add(summaryColumn2);
            ordersDescriptor.SummaryRows.Add(summaryRow2);

            // Have Extra Section bar cover some cells.
            this.gridGroupingControl1.TableModel.QueryCoveredRange += new GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange);

            // Provide contents to be displayed in cell
            this.gridGroupingControl1.QueryCellStyleInfo    += new GridTableCellStyleInfoEventHandler(gridGroupingControl1_QueryCellStyleInfo);
            this.gridGroupingControl1.TableControlCellDrawn += new GridTableControlDrawCellEventHandler(gridGroupingControl1_TableControlCellDrawn);

            // Move Freight column a bit to the left
            this.gridGroupingControl1.TableDescriptor.VisibleColumns.Move(this.gridGroupingControl1.TableDescriptor.VisibleColumns.IndexOf("Freight"), 4);


            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("EmployeeID");
            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("ShipCountry");
        }
Esempio n. 8
0
        private void GridSettings()
        {
            dataSet1 = new DataSet();

            ReadXml(dataSet1, @"Data\Expand.xml");

            dataSet1.Tables[1].TableName = "Products";
            dataSet1.Tables[2].TableName = "OrderDetails";
            dataSet1.Tables[3].TableName = "Suppliers";

            dataSet1.Relations.Add(
                dataSet1.Tables[0].Columns["CategoryID"],
                dataSet1.Tables[1].Columns["CategoryID"]);
            dataSet1.Relations[0].RelationName = "Category_Products";

            dataSet1.Relations.Add(
                dataSet1.Tables[1].Columns["ProductID"],
                dataSet1.Tables[2].Columns["ProductID"]);
            dataSet1.Relations[1].RelationName = "Products_OrderDetails";

            this.gridGroupingControl1.DataSource = dataSet1.Tables[0];


            this.gridGroupingControl1.TableControl.DpiAware = true;
            this.gridGroupingControl1.ThemesEnabled         = true;
            this.gridGroupingControl1.GridVisualStyles      = Syncfusion.Windows.Forms.GridVisualStyles.Metro;
            this.gridGroupingControl1.ShowGroupDropArea     = true;
            this.gridGroupingControl1.TableDescriptor.Appearance.AnyCell.Font.Facename = "Segoe UI";
            this.gridGroupingControl1.TableDescriptor.Appearance.AnyCell.Font.Size     = 10f;

            #region Summaries
            GridTableDescriptor categoriesTableDescriptor = (GridTableDescriptor)this.gridGroupingControl1.Engine.TableDescriptor;

            //Creating a new SummaryColumnDescriptor.
            GridSummaryColumnDescriptor countCat = new GridSummaryColumnDescriptor();
            //Setting it's properties.
            countCat.SummaryType = SummaryType.Count;

            //Initializing it to the Column it is associated with.
            countCat.DataMember = "CategoryID";

            //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor.
            GridSummaryRowDescriptor categoriesSummaryRow = new GridSummaryRowDescriptor();
            categoriesSummaryRow.SummaryColumns.Add(countCat);
            //Adding the SummaryRowDescriptor to the  TableDesriptor.
            categoriesTableDescriptor.SummaryRows.Add(categoriesSummaryRow);
            #endregion

            // expand a specific record, search for groups etc.
            Table categoriesTable = this.gridGroupingControl1.Engine.Table;
            Table productsTable   = categoriesTable.RelatedTables["Products"];

            this.gridGroupingControl1.ShowGroupDropArea = true;

            this.gridGroupingControl1.Table.Records[0].IsExpanded = true;
            categoriesTable.Records[0].IsExpanded = true;

            //Navigate to other control using tabkey navigation
            this.gridGroupingControl1.WantTabKey = false;

            #region Setting Header Text
            this.gridGroupingControl1.TableDescriptor.Columns["CategoryID"].HeaderText   = "Category ID";
            this.gridGroupingControl1.TableDescriptor.Columns["CategoryName"].HeaderText = "Category Name";

            GridTableDescriptor childTableDescriptor = this.gridGroupingControl1.GetTableDescriptor("Products");
            childTableDescriptor.Columns["ProductID"].HeaderText       = "Product ID";
            childTableDescriptor.Columns["ProductName"].HeaderText     = "Product Name";
            childTableDescriptor.Columns["UnitsInStock"].HeaderText    = "Units In Stock";
            childTableDescriptor.Columns["ReorderLevel"].HeaderText    = "Reorder Level";
            childTableDescriptor.Columns["QuantityPerUnit"].HeaderText = "Quantity Per Unit";
            childTableDescriptor.Columns["UnitPrice"].HeaderText       = "Unit Price";
            childTableDescriptor.Columns["UnitsOnOrder"].HeaderText    = "Unit on Order";

            GridTableDescriptor nestedTableDescriptor = this.gridGroupingControl1.GetTableDescriptor("OrderDetails");
            nestedTableDescriptor.Columns["OrderID"].HeaderText   = "Order ID";
            nestedTableDescriptor.Columns["UnitPrice"].HeaderText = "Unit price";

            #endregion
        }
Esempio n. 9
0
        /// <summary>
        /// Setting Maual relation to the GridGroupingControl.
        /// </summary>

        private void SampleCustomization()
        {
            #region DataTable

            DataSet ds = new DataSet();
            ReadXml(ds, @"Expand.xml");

            ds.Tables[1].TableName = "Products";
            ds.Tables[2].TableName = "OrderDetails";
            ds.Tables[3].TableName = "Suppliers";

            ds.Relations.Add(
                ds.Tables[0].Columns["CategoryID"],
                ds.Tables[1].Columns["CategoryID"]);
            ds.Relations[0].RelationName = "Category_Products";

            ds.Relations.Add(
                ds.Tables[1].Columns["ProductID"],
                ds.Tables[2].Columns["ProductID"]);
            ds.Relations[1].RelationName = "Products_OrderDetails";

            #endregion

            this.groupingGrid1.DataSource = ds.Tables[0];

            GridEngine engine = this.groupingGrid1.Engine;

            engine.TopLevelGroupOptions.ShowCaption = true;

            // Record summary for Categories Tables

            GridTableDescriptor categoriesTableDescriptor = (GridTableDescriptor)engine.TableDescriptor;

            categoriesTableDescriptor.Columns.Clear();
            categoriesTableDescriptor.Columns.Add("CategoryID");
            categoriesTableDescriptor.Columns.Add("CategoryName");
            categoriesTableDescriptor.Columns.Add("Description");

            categoriesTableDescriptor.Columns["CategoryName"].Width = 200;
            //Creating a new SummaryColumnDescriptor.
            GridSummaryColumnDescriptor countCat = new GridSummaryColumnDescriptor("RecordCount");
            //Setting it's properties.
            countCat.SummaryType = SummaryType.Count;
            countCat.Style       = GridSummaryStyle.FillRow;
            //Initializing it to the Column it is associated with.
            countCat.DataMember = "CategoryID";
            //Mentioning the format of display.
            countCat.Format = "      {Count} Records.";

            //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor.
            GridSummaryRowDescriptor categoriesSummaryRow = new GridSummaryRowDescriptor("RecordCountRow");
            categoriesSummaryRow.SummaryColumns.Add(countCat);
            //Adding the SummaryRowDescriptor to the  TableDesriptor.
            categoriesTableDescriptor.SummaryRows.Add(categoriesSummaryRow);

            // Group Products table by "SupplierID"
            RelationDescriptor  productsRelationDescriptor = categoriesTableDescriptor.Relations["Products"];
            GridTableDescriptor productsTableDescriptor    = (GridTableDescriptor)productsRelationDescriptor.ChildTableDescriptor;
            productsTableDescriptor.GroupedColumns.Add("SupplierID");

            // Group OrderDetails table by "Discount"
            // Add Total = "[UnitPrice]*[Quantity]" expression field
            // Add Summaries for Total and Average for UnitPrice.

            RelationDescriptor  orderDetailsRelationDescriptor = productsTableDescriptor.Relations["OrderDetails"];
            GridTableDescriptor orderDetailsTableDescriptor    = (GridTableDescriptor)orderDetailsRelationDescriptor.ChildTableDescriptor;

            ExpressionFieldDescriptor ed = new ExpressionFieldDescriptor("Total", "[UnitPrice]*[Quantity]");
            ed.DefaultValue = "";
            orderDetailsTableDescriptor.ExpressionFields.Add(ed);
            orderDetailsTableDescriptor.GroupedColumns.Add("Discount");
            //Adding the SummaryColumnDescriptor to the SummaryRowDescriptor.
            GridSummaryRowDescriptor orderDetailsSummaryRow = new GridSummaryRowDescriptor("Total");
            orderDetailsTableDescriptor.SummaryRows.Add(orderDetailsSummaryRow);
            //Creating a new SummaryColumnDescriptor.
            GridSummaryColumnDescriptor totalSum = new GridSummaryColumnDescriptor("Total");
            //Setting it's properties.
            totalSum.SummaryType = SummaryType.DoubleAggregate;
            totalSum.Style       = GridSummaryStyle.Column;
            //Initializing it to the Column it is associated with.
            totalSum.DataMember    = "Total";
            totalSum.DisplayColumn = "Total";
            totalSum.Format        = "Sum={Sum}";
            orderDetailsSummaryRow.SummaryColumns.Add(totalSum);


            orderDetailsTableDescriptor.Columns["Total"].Width = 70;

            //Creating a new SummaryColumnDescriptor.
            GridSummaryColumnDescriptor avgUnitPrice = new GridSummaryColumnDescriptor("AvgUnitPrice");
            //Setting it's properties.
            avgUnitPrice.SummaryType   = SummaryType.DoubleAggregate;
            avgUnitPrice.Style         = GridSummaryStyle.Column;
            avgUnitPrice.DataMember    = "UnitPrice";
            avgUnitPrice.DisplayColumn = "UnitPrice";
            avgUnitPrice.Format        = "Avg={Average:#.0}";
            orderDetailsSummaryRow.SummaryColumns.Add(avgUnitPrice);

            // expand a specific record, search for groups etc.
            Table categoriesTable = engine.Table;//.RelatedTables["Categories"];
            Console.WriteLine(categoriesTable.ToString());

            Table productsTable = categoriesTable.RelatedTables["Products"];
            Console.WriteLine(productsTable.ToString());

            // Get the child table in the products table that is assocuated with category "1"
            ChildTable product1 = (ChildTable)productsTable.TopLevelGroup.Groups["1"];
            Console.WriteLine(product1.ToString());
            Console.WriteLine(product1.Groups[0].ToString());

            // Get the child table in the products table that is assocuated with category "1"
            ChildTable product21 = (ChildTable)productsTable.TopLevelGroup.Groups["8"];
            Console.WriteLine(product21.ToString());
            Console.WriteLine(product21.Groups[0].Records[0].ToString());

            // Show me the associated "NestedTable" element of the categories table (the NestedTable
            // element established the link between parent table and a nested child table)
            Console.WriteLine(product21.Groups[0].Records[0].ParentChildTable.ParentNestedTable);

            // Expand the product for category 8
            product21.IsExpanded = true;
            product21.ParentNestedTable.IsExpanded = true;
            product21.ParentNestedTable.ParentRecord.IsExpanded = true;

            // When you assign a "DataSet" as a datasource, the DataSet is a list with one record (not allowing AddNew) with nested tables.
            // Expand the first record so that tables are shown.
            engine.Table.TopLevelGroup.Records[0].IsExpanded = true;

            // Sort  product table by ProductName
            product21.ParentTable.TableDescriptor.SortedColumns.Add("ProductName");

            // Find group for supplier id 21
            Group supplier21Group = product21.Groups["21"];

            // Find productname Spegesild in that group
            int index = supplier21Group.Records.FindRecord("Spegesild");

            // Print out the row index and record index
            Record r = supplier21Group.Records[index];
            Console.WriteLine("Found: " + r.ToString());
            Console.WriteLine("RowIndex " + engine.Table.NestedDisplayElements.IndexOf(r).ToString());
            Console.WriteLine("Record Index " + engine.Table.Records.IndexOf(r).ToString());

            // Dump out nested display elements to console



            this.groupingGrid1.Table.Records[0].IsExpanded    = true;
            this.groupingGrid1.Table.TopLevelGroup.IsExpanded = true;


            engine.ChildGroupOptions.ShowCaption       = true;
            engine.NestedTableGroupOptions.ShowCaption = true;



            // Adding GroupDropAreas for nested tables.
            groupingGrid1.AddGroupDropArea((GridTable)productsTable);
            groupingGrid1.AddGroupDropArea((GridTable)productsTable.RelatedTables[0]);
            groupingGrid1.ShowGroupDropArea = true;

            //Navigate to other control using tabkey navigation
            groupingGrid1.WantTabKey = false;

            // Make Spegesild current record
            if (r != null)
            {
                r.SetCurrent();

                // Expand record and nested tables
                r.IsExpanded = true;
                r.NestedTables[0].IsExpanded = true;

                Record orderDetailsRecords = r.NestedTables[0].ChildTable.GetFirstRecord();
                // Expand Group record belongs to
                orderDetailsRecords.ParentGroup.IsExpanded = true;

                // Scroll this record in view.
                groupingGrid1.TableControl.ScrollInView(orderDetailsRecords);
                groupingGrid1.TableControl.LeftColIndex = 1;
            }
        }
Esempio n. 10
0
        private void FormatColumnas()
        {
            GGCPersLiq.TableOptions.ListBoxSelectionMode = SelectionMode.One;
            GGCPersLiq.TableOptions.SelectionBackColor   = Color.SteelBlue;
            GGCPersLiq.TableOptions.SelectionTextColor   = Color.WhiteSmoke;
            GridSummaryColumnDescriptor sd0 = new GridSummaryColumnDescriptor();

            sd0.DataMember    = "Soles";
            sd0.DisplayColumn = "Soles";
            sd0.Format        = "{Sum:#,##.00}";
            sd0.SummaryType   = SummaryType.DoubleAggregate;
            GGCPersLiq.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Sum", "", sd0));
            GGCPersLiq.GridGroupDropArea.DragColumnHeaderText = "Agregue el campo a agrupar a esta área";
            sd0.Appearance.AnyCell.HorizontalAlignment        = GridHorizontalAlignment.Right;
            sd0.Appearance.AnyCell.BackColor = Color.SteelBlue;
            sd0.Appearance.AnyCell.TextColor = Color.WhiteSmoke;
            GGCPersLiq.TableDescriptor.Appearance.AlternateRecordFieldCell.BackColor = Color.Lavender;
            GGCPersLiq.TableDescriptor.Columns[0].Width     = 30;
            GGCPersLiq.TableDescriptor.Columns[1].ReadOnly  = true;
            GGCPersLiq.TableDescriptor.Columns[1].Width     = 40;
            GGCPersLiq.TableDescriptor.Columns[1].ReadOnly  = true;
            GGCPersLiq.TableDescriptor.Columns[2].Width     = 80;
            GGCPersLiq.TableDescriptor.Columns[2].ReadOnly  = true;
            GGCPersLiq.TableDescriptor.Columns[3].Width     = 100;
            GGCPersLiq.TableDescriptor.Columns[3].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[4].Width     = 160;
            GGCPersLiq.TableDescriptor.Columns[4].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[5].Width     = 150;
            GGCPersLiq.TableDescriptor.Columns[5].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[6].Width     = 50;
            GGCPersLiq.TableDescriptor.Columns[6].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[7].Width     = 40;
            GGCPersLiq.TableDescriptor.Columns[7].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[8].Width     = 100;
            GGCPersLiq.TableDescriptor.Columns[8].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[9].Width     = 30;
            GGCPersLiq.TableDescriptor.Columns[9].ReadOnly  = false;
            GGCPersLiq.TableDescriptor.Columns[10].Width    = 40;
            GGCPersLiq.TableDescriptor.Columns[10].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[11].Width    = 60;
            GGCPersLiq.TableDescriptor.Columns[11].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[12].Width    = 60;
            GGCPersLiq.TableDescriptor.Columns[12].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[13].Width    = 70;
            GGCPersLiq.TableDescriptor.Columns[13].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[14].Width    = 60;
            GGCPersLiq.TableDescriptor.Columns[14].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[15].Width    = 60;
            GGCPersLiq.TableDescriptor.Columns[15].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[16].Width    = 90;
            GGCPersLiq.TableDescriptor.Columns[16].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[17].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[17].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[18].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[18].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[19].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[19].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[20].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[20].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[21].Width    = 50;
            GGCPersLiq.TableDescriptor.Columns[21].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[22].Width    = 120;
            GGCPersLiq.TableDescriptor.Columns[22].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[23].Width    = 50;
            GGCPersLiq.TableDescriptor.Columns[23].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[24].Width    = 50;
            GGCPersLiq.TableDescriptor.Columns[24].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[25].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[25].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[26].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[26].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[27].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[27].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[28].Width    = 50;
            GGCPersLiq.TableDescriptor.Columns[28].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[29].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[29].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[30].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[30].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[31].Width    = 100;
            GGCPersLiq.TableDescriptor.Columns[31].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[32].Width    = 30;
            GGCPersLiq.TableDescriptor.Columns[32].ReadOnly = false;
            GGCPersLiq.TableDescriptor.Columns[33].Width    = 30;
            GGCPersLiq.TableDescriptor.Columns[33].ReadOnly = false;
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Sel");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Item");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("idtipodocumento");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("NroDoc");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Denominacion");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("idpartidasprincipales");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("idmoneda");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Pendiente");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("observaciones");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Fecha");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("fecharegistro");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("usuario");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("DP");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Horas");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Proyecto");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("idproyecto");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("Archivo");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("numeroruc");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("idformapago");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("documentopago");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("FPP");
            GGCPersLiq.TableDescriptor.VisibleColumns.Remove("FP");
        }
Esempio n. 11
0
        /// <summary>
        /// Grid Settings for better Look and Feel.
        /// </summary>
        private void GridSettings()
        {
            GridTableDescriptor ordersDescriptor = this.gridGroupingControl1.TableDescriptor;

            // Add Unbound
            ordersDescriptor.UnboundFields.Add("ShipVia_CompanyName");

            // Callback for conversion
            ordersDescriptor.QueryValue += new FieldValueEventHandler(ordersDescriptor_QueryValue);

            // Hide it.
            ordersDescriptor.VisibleColumns.Remove("ShipVia_CompanyName");

            // Use it for grouping.
            ordersDescriptor.GroupedColumns.Add("ShipVia_CompanyName");

            ordersDescriptor.TopLevelGroupOptions.ShowCaptionSummaryCells = false;

            // not neeeded.
            ordersDescriptor.PrimaryKeyColumns.Clear();


            // You can define a summary row and mark it hidden.
            // In that summary row you can add a column and set it's mapping name (and DisplayColumn) to be Freight
            GridSummaryColumnDescriptor summaryColumn1 = new GridSummaryColumnDescriptor("FreightAverage", SummaryType.DoubleAggregate, "Freight", "{Average:###.00}");
            GridSummaryRowDescriptor    summaryRow1    = new GridSummaryRowDescriptor();

            summaryRow1.Name    = "Caption";
            summaryRow1.Visible = false;
            summaryRow1.SummaryColumns.Add(summaryColumn1);
            ordersDescriptor.SummaryRows.Add(summaryRow1);

            // This is a second row, not marked hidden and therefore shown at the end of the group.
            GridSummaryColumnDescriptor summaryColumn2 = new GridSummaryColumnDescriptor("FreightTotal", SummaryType.DoubleAggregate, "Freight", "{Average:###.00}");
            GridSummaryRowDescriptor    summaryRow2    = new GridSummaryRowDescriptor();

            summaryRow2.Name    = "Bottom";
            summaryRow2.Visible = true;
            summaryRow2.SummaryColumns.Add(summaryColumn2);
            ordersDescriptor.SummaryRows.Add(summaryRow2);

            // Here you define the summary row that should be used for displaying summaries in caption bar.
            ordersDescriptor.ChildGroupOptions.ShowCaptionSummaryCells = true;
            ordersDescriptor.ChildGroupOptions.ShowSummaries           = true;
            ordersDescriptor.ChildGroupOptions.CaptionSummaryRow       = "Caption";

            // Let's you hide/show the second row in child groups.
            ordersDescriptor.ChildGroupOptions.ShowSummaries = false;

            // Move Freight column ahead
            // ordersDescriptor.VisibleColumns.LoadDefault();
            int count = ordersDescriptor.VisibleColumns.Count; // force populating VisibleColumns

            ordersDescriptor.VisibleColumns.Remove("Freight");
            ordersDescriptor.VisibleColumns.Insert(3, new GridVisibleColumnDescriptor("Freight"));


            // Minor customization: Have Caption bar cover some cells.
            this.gridGroupingControl1.TableModel.QueryCoveredRange += new GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange);
            captionCoverCols = 2;


            this.gridGroupingControl1.Appearance.GroupCaptionCell.BackColor              = this.gridGroupingControl1.Appearance.RecordFieldCell.BackColor;
            this.gridGroupingControl1.Appearance.GroupCaptionCell.Borders.Top            = new GridBorder(GridBorderStyle.Standard);
            this.gridGroupingControl1.Appearance.GroupCaptionCell.CellType               = "Static";
            this.gridGroupingControl1.TableDescriptor.Appearance.AnyHeaderCell.Font.Bold = true;
            this.gridGroupingControl1.TableOptions.CaptionRowHeight = this.gridGroupingControl1.TableOptions.RecordRowHeight;

            this.gridGroupingControl1.ChildGroupOptions.ShowAddNewRecordBeforeDetails = false;

            gridGroupingControl1.Table.CurrentRecord = gridGroupingControl1.Table.Records[0];
            this.gridGroupingControl1.TableOptions.GridVisualStyles = Syncfusion.Windows.Forms.GridVisualStyles.Office2007Blue;
            this.gridGroupingControl1.TableOptions.GridLineBorder   = new Syncfusion.Windows.Forms.Grid.GridBorder(GridBorderStyle.Solid, Color.FromArgb(208, 215, 229), GridBorderWeight.Thin);
            this.gridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
            this.gridGroupingControl1.TopLevelGroupOptions.ShowCaption = false;
            gridGroupingControl1.Appearance.AnyCell.Font.Facename      = "Segoe UI";
            this.BackColor = Color.FromArgb(223, 227, 239);
            this.gridGroupingControl1.GridVisualStyles = GridVisualStyles.Metro;
            this.propertyGrid1.SelectedObject          = this.gridGroupingControl1;
            this.propertyGrid1.BackColor = Color.White;

            //Navigate to other control using tabkey navigation
            this.gridGroupingControl1.WantTabKey = false;

            t.Tick += new EventHandler(t_Tick);

            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                Regex  rex   = new Regex(@"\p{Lu}");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
        }
Esempio n. 12
0
        /// <summary>
        /// SortBySummaryInCaption sample Customizations
        /// </summary>
        private void SampleCustomization()
        {
            InitializeDataSet();
            GridTableDescriptor ordersDescriptor = this.gridGroupingControl1.TableDescriptor;

            // You can define a summary row and mark it hidden.
            // In that summary row you can add a column and set it's mapping name (and DisplayColumn) to be Freight
            GridSummaryColumnDescriptor summaryColumn1 = new GridSummaryColumnDescriptor("FreightAverage", SummaryType.DoubleAggregate, "Freight", "{Average:###.00}");
            GridSummaryRowDescriptor    summaryRow1    = new GridSummaryRowDescriptor();

            summaryRow1.Name    = "Caption";
            summaryRow1.Visible = false;
            summaryRow1.SummaryColumns.Add(summaryColumn1);
            ordersDescriptor.SummaryRows.Add(summaryRow1);

            // This is a second row, not marked hidden and therefore shown at the end of the group.
            GridSummaryColumnDescriptor summaryColumn2 = new GridSummaryColumnDescriptor("FreightTotal", SummaryType.DoubleAggregate, "Freight", "{Average:###.00}");
            GridSummaryRowDescriptor    summaryRow2    = new GridSummaryRowDescriptor();

            summaryRow2.Name    = "Bottom";
            summaryRow2.Visible = true;
            summaryRow2.SummaryColumns.Add(summaryColumn2);
            ordersDescriptor.SummaryRows.Add(summaryRow2);

            // Here you define the summary row that should be used for displaying summaries in caption bar.
            ordersDescriptor.ChildGroupOptions.ShowCaptionSummaryCells = true;
            ordersDescriptor.ChildGroupOptions.CaptionSummaryRow       = "Caption";

            // Let's you hide/show the second row in child groups.
            ordersDescriptor.ChildGroupOptions.ShowSummaries = false;

            // Move Freight column ahead
            // ordersDescriptor.VisibleColumns.LoadDefault();
            int count = ordersDescriptor.VisibleColumns.Count; // force populating VisibleColumns

            ordersDescriptor.VisibleColumns.Remove("Freight");
            ordersDescriptor.VisibleColumns.Insert(3, new GridVisibleColumnDescriptor("Freight"));

            // Minor customization: Have Caption bar cover some cells.
            this.gridGroupingControl1.TableModel.QueryCoveredRange += new GridQueryCoveredRangeEventHandler(TableModel_QueryCoveredRange);
            captionCoverCols = 2;

            this.gridGroupingControl1.Appearance.GroupCaptionCell.BackColor   = this.gridGroupingControl1.Appearance.RecordFieldCell.BackColor;
            this.gridGroupingControl1.Appearance.GroupCaptionCell.Borders.Top = new GridBorder(GridBorderStyle.Standard);
            this.gridGroupingControl1.Appearance.GroupCaptionCell.CellType    = "Static";

            this.gridGroupingControl1.TableOptions.CaptionRowHeight = this.gridGroupingControl1.TableOptions.RecordRowHeight;

            this.gridGroupingControl1.ChildGroupOptions.ShowAddNewRecordBeforeDetails = false;

            // Specify group sort order behavoir when adding SortColumnDescriptor to GroupedColumns
            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Clear();
            SortColumnDescriptor gsd = new SortColumnDescriptor("ShipCountry");

            // specify your own Comparer
            //gsd.GroupSortOrderComparer = new ShipViaComparer(summaryColumn1.GetSummaryDescriptorName(), "Average");

            // or specify a summary name and the property (values will be determined using reflection)
            gsd.SetGroupSummarySortOrder(summaryColumn1.GetSummaryDescriptorName(), "Average");

            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add(gsd);
            // this should always be true since changing one record can cause the whole group to move
            // to a different position.
            this.gridGroupingControl1.InvalidateAllWhenListChanged = true;
            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"\p{Lu}");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
        }
Esempio n. 13
0
        /// <summary>
        /// CustomSummary sample Customizations
        /// </summary>
        private void SampleCustomization()
        {
            // Setup a integrated summary
            GridSummaryColumnDescriptor sd0 = new GridSummaryColumnDescriptor();

            //sd0.Name = "QuantityAvg";
            sd0.DataMember    = "Quantity";
            sd0.DisplayColumn = "Quantity";
            sd0.Format        = "{Average:#.00}";
            sd0.SummaryType   = SummaryType.DoubleAggregate;
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row 0", "Average", sd0));

            // Setup custom summaries
            this.gridGroupingControl1.QueryCustomSummary += new GridQueryCustomSummaryEventHandler(gridGroupingControl1_QueryCustomSummary);

            GridSummaryColumnDescriptor sd1 = new GridSummaryColumnDescriptor();

            sd1.Name          = "QuantityTotal";
            sd1.DataMember    = "Quantity";
            sd1.DisplayColumn = "Quantity";
            sd1.Format        = "{Total}";
            sd1.SummaryType   = SummaryType.Custom;
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row 1", "Total", sd1));

            GridSummaryColumnDescriptor sd2 = new GridSummaryColumnDescriptor();

            sd2.Name          = "QuantityDistinctCount";
            sd2.DataMember    = "Quantity";
            sd2.DisplayColumn = "Quantity";
            sd2.Format        = "{Count}";
            sd2.SummaryType   = SummaryType.Custom;
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row 2", "DistinctCount", sd2));


            GridSummaryColumnDescriptor sd3 = new GridSummaryColumnDescriptor();

            sd3.Name          = "QuantityMedian";
            sd3.DataMember    = "Quantity";
            sd3.DisplayColumn = "Quantity";
            sd3.Format        = "{Median}";
            sd3.SummaryType   = SummaryType.Custom;
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("Row 3", "Statistic Median", sd3));


            // Setup running totals by displaying the value of a custom counter in an unbound field
            FieldDescriptor unboundField = new FieldDescriptor("QuantityCount", "", false, "");

            unboundField.ReadOnly = false;
            this.gridGroupingControl1.TableDescriptor.UnboundFields.Add(unboundField);

            // Routine that queries for the value
            this.gridGroupingControl1.TableDescriptor.QueryValue += new FieldValueEventHandler(unboundField_QueryValue);
            this.gridGroupingControl1.TableDescriptor.SaveValue  += new FieldValueEventHandler(unboundField_SaveValue);

            FieldDescriptor unboundField2 = new FieldDescriptor("QuantityCount2", "", false, "");

            this.gridGroupingControl1.TableDescriptor.UnboundFields.Add(unboundField2);

            this.gridGroupingControl1.TableDescriptor.Columns.IsModified = true;

            Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor gridColumnDescriptor1 = new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor();
            Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor gridColumnDescriptor2 = new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor();
            gridColumnDescriptor1.MappingName = "OrderID";
            this.gridGroupingControl1.TableDescriptor.Columns.AddRange(new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor[] {
                gridColumnDescriptor1,
                new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("ProductID"),
                new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("UnitPrice"),
                new Syncfusion.Windows.Forms.Grid.Grouping.GridColumnDescriptor("Quantity"),
            });

            foreach (GridColumnDescriptor col in this.gridGroupingControl1.TableDescriptor.Columns)
            {
                Regex  rex   = new Regex(@"\p{Lu}");
                int    index = rex.Match(col.MappingName.Substring(1)).Index;
                string name  = "";
                while (index > 0)
                {
                    name += col.MappingName.Substring(0, index + 1) + " ";
                    string secondName = col.MappingName.Substring(index + 1);
                    index = rex.Match(secondName.Substring(1)).Index;
                    while (index > 0)
                    {
                        name += secondName.Substring(0, index + 1) + " ";
                        index = rex.Match(col.MappingName.Substring(name.Replace(" ", "").Length).Substring(1)).Index;
                    }
                }
                name          += col.MappingName.Substring(name.Replace(" ", "").Length);
                col.HeaderText = name;
            }
            GridColumnDescriptor columnDescriptor = new GridColumnDescriptor(unboundField);

            columnDescriptor.HeaderText = "Quantity Count";
            columnDescriptor.Appearance.AnyRecordFieldCell.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(245)), ((System.Byte)(227))));
            this.gridGroupingControl1.TableDescriptor.Columns.Add(columnDescriptor);

            GridColumnDescriptor columnDescriptor2 = new GridColumnDescriptor(unboundField2);

            columnDescriptor2.HeaderText = "Quantity Count 2";
            columnDescriptor2.Appearance.AnyRecordFieldCell.Interior = new Syncfusion.Drawing.BrushInfo(System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(245)), ((System.Byte)(227))));
            this.gridGroupingControl1.TableDescriptor.Columns.Add(columnDescriptor2);

            // Setup custom counter
            this.gridGroupingControl1.Table.QueryCustomCount     += new CustomCountEventHandler(Table_QueryCustomCount);
            this.gridGroupingControl1.CurrentRecordContextChange += new CurrentRecordContextChangeEventHandler(gridGroupingControl1_CurrentRecordContextChange);

            // Assign data source
            this.gridGroupingControl1.DataMember = null;
            this.gridGroupingControl1.DataSource = this.dataSet11.Order_Details;

            quantityFieldDescriptor = this.gridGroupingControl1.TableDescriptor.Fields["Quantity"];

            // Add a filter so that we can check out difference between VisibleCustomCount (only records that meet criteria are counted)
            // and CustomCount (all records are counted)
            this.gridGroupingControl1.TableDescriptor.RecordFilters.Add("[UnitPrice] > 20");

            this.gridGroupingControl1.FilterRuntimeProperties = true;

            this.gridGroupingControl1.TableControlCellClick += new GridTableControlCellClickEventHandler(gridGroupingControl1_TableControlCellClick);
            this.gridGroupingControl1.TableDescriptor.Columns["QuantityCount"].AllowGroupByColumn  = false;
            this.gridGroupingControl1.TableDescriptor.Columns["QuantityCount2"].AllowGroupByColumn = false;

            //Hook-up the QueryColWidth event to set the Column width.
            this.gridGroupingControl1.TableModel.QueryColWidth += new GridRowColSizeEventHandler(TableModel_QueryColWidth);
        }
Esempio n. 14
0
        /// <summary>
        /// GridGrouping control getting started customization.
        /// </summary>
        private void GridSettings()
        {
            #region SetUpGroupingGrid

            DataTable parentTable     = GetParentTable();
            DataTable childTable      = GetChildTable();
            DataTable grandChildTable = GetGrandChildTable();

            //Add Summary row to parent table
            GridSummaryColumnDescriptor gridSummaryColumnDescriptor = new GridSummaryColumnDescriptor();
            gridSummaryColumnDescriptor.DisplayColumn = "GroupID";
            gridSummaryColumnDescriptor.Format        = "  {Count} Records.";
            gridSummaryColumnDescriptor.Name          = "SummaryColumn";
            gridSummaryColumnDescriptor.SummaryType   = Syncfusion.Grouping.SummaryType.Count;
            this.gridGroupingControl1.TableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("SummaryRow", new GridSummaryColumnDescriptor[] {
                gridSummaryColumnDescriptor
            }));


            // Manually specify relations in grouping engine. The DataSet does not need to have any DataRelations.
            // This is the same approach that should be used if you want to set up relation ships
            // between independent IList.
            GridRelationDescriptor parentToChildRelationDescriptor = new GridRelationDescriptor();
            parentToChildRelationDescriptor.ChildTableName = "MyChildTable";                // same as SourceListSetEntry.Name for childTable (see below)
            parentToChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            parentToChildRelationDescriptor.RelationKeys.Add("parentID", "ParentID");

            //Add Summary Row to child table
            gridSummaryColumnDescriptor = new GridSummaryColumnDescriptor();
            gridSummaryColumnDescriptor.DisplayColumn = "ChildGroupID";
            gridSummaryColumnDescriptor.Format        = "  {Count} Records.";
            gridSummaryColumnDescriptor.Name          = "SummaryColumn";
            gridSummaryColumnDescriptor.SummaryType   = Syncfusion.Grouping.SummaryType.Count;
            parentToChildRelationDescriptor.ChildTableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("SummaryRow", new Syncfusion.Windows.Forms.Grid.Grouping.GridSummaryColumnDescriptor[] {
                gridSummaryColumnDescriptor
            }));


            // Add relation to ParentTable
            gridGroupingControl1.TableDescriptor.Relations.Add(parentToChildRelationDescriptor);

            GridRelationDescriptor childToGrandChildRelationDescriptor = new GridRelationDescriptor();
            childToGrandChildRelationDescriptor.ChildTableName = "MyGrandChildTable";              // same as SourceListSetEntry.Name for grandChhildTable (see below)
            childToGrandChildRelationDescriptor.RelationKind   = RelationKind.RelatedMasterDetails;
            childToGrandChildRelationDescriptor.RelationKeys.Add("childID", "ChildID");

            //Add Summary row to GrandChildTable
            gridSummaryColumnDescriptor = new GridSummaryColumnDescriptor();
            gridSummaryColumnDescriptor.DisplayColumn = "GrandChildGroupID";
            gridSummaryColumnDescriptor.Format        = "  {Count} Records.";
            gridSummaryColumnDescriptor.Name          = "SummaryColumn";
            gridSummaryColumnDescriptor.SummaryType   = Syncfusion.Grouping.SummaryType.Count;
            childToGrandChildRelationDescriptor.ChildTableDescriptor.SummaryRows.Add(new GridSummaryRowDescriptor("SummaryRow", new GridSummaryColumnDescriptor[] {
                gridSummaryColumnDescriptor
            }));


            // Add relation to ChildTable
            parentToChildRelationDescriptor.ChildTableDescriptor.Relations.Add(childToGrandChildRelationDescriptor);

            // Register any DataTable/IList with SourceListSet, so that RelationDescriptor can resolve the name
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyParentTable", parentTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyChildTable", childTable);
            this.gridGroupingControl1.Engine.SourceListSet.Add("MyGrandChildTable", grandChildTable);

            this.gridGroupingControl1.DataSource        = parentTable;
            this.gridGroupingControl1.ShowGroupDropArea = true;
            this.gridGroupingControl1.AddGroupDropArea("MyChildTable");
            this.gridGroupingControl1.AddGroupDropArea("MyGrandChildTable");


            //Sync the col width with nested table to avoid messing up of RecordPreviewCell

            // The TrackWidthOfParentColumn propetry of a column descriptor ensures that
            // columns are aligned and stay in sync.

            this.gridGroupingControl1.TableDescriptor.Columns[0].Width = 200;
            this.gridGroupingControl1.TableDescriptor.Columns[1].Width = 150;
            this.gridGroupingControl1.TableDescriptor.Columns[2].Width = 150;

            //// synchronize width of columns in child record with width of column in parent record.
            for (int n = 0; n < 3; n++)
            {
                parentToChildRelationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = gridGroupingControl1.TableDescriptor.Columns[n].Name;
            }

            ///same for grandchild table.
            for (int n = 0; n < 3; n++)
            {
                childToGrandChildRelationDescriptor.ChildTableDescriptor.Columns[n].TrackWidthOfParentColumn = parentToChildRelationDescriptor.ChildTableDescriptor.Columns[n].Name;
            }


            this.gridGroupingControl1.TableDescriptor.GroupedColumns.Add("GroupID");
            this.gridGroupingControl1.TableOptions.ShowRecordPreviewRow  = true;
            this.gridGroupingControl1.ChildGroupOptions.ShowGroupPreview = true;
            gridGroupingControl1.Appearance.AnyCell.TextColor            = Color.MidnightBlue;
            //this.gridGroupingControl1.TableDescriptor.Columns["GroupID"].Appearance.AnyHeaderCell.HorizontalAlignment = GridHorizontalAlignment.Right;
            //this.gridGroupingControl1.TableDescriptor.Columns["GroupID"].Appearance.AnyHeaderCell.VerticalAlignment = GridVerticalAlignment.Bottom;
            this.gridGroupingControl1.TableDescriptor.Columns["GroupID"].HeaderText    = "Group ID";
            this.gridGroupingControl1.TableDescriptor.Columns["parentID"].HeaderText   = "Parent ID";
            this.gridGroupingControl1.TableDescriptor.Columns["ParentName"].HeaderText = "Parent Name";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["childID"].HeaderText      = "Child ID";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Columns["ChildGroupID"].HeaderText = "Child Group ID";

            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Relations[0].ChildTableDescriptor.Columns["GrandChildID"].HeaderText      = "Grand Child ID";
            this.gridGroupingControl1.TableDescriptor.Relations[0].ChildTableDescriptor.Relations[0].ChildTableDescriptor.Columns["GrandChildGroupID"].HeaderText = "Grand Child Group ID";
            this.gridGroupingControl1.Table.DefaultColumnHeaderRowHeight = 30;

            #endregion

            this.comboBox1.Items.Add(ConverterOptions.Default);
            this.comboBox1.Items.Add(ConverterOptions.Visible);
            this.comboBox1.SelectedIndex          = 0;
            this.checkBox2.Checked                = true;
            this.checkBox3.Checked                = true;
            this.checkBox5.Checked                = true;
            this.checkBox6.Checked                = true;
            this.colorPickerButton1.SelectedColor = Color.Empty;
            this.colorPickerButton2.SelectedColor = Color.Empty;
            this.comboBox1.SelectedIndexChanged  += new EventHandler(comboBox1_SelectedIndexChanged);

            //Navigate to other control using tabkey navigation
            this.gridGroupingControl1.WantTabKey = false;
        }
Esempio n. 15
0
        private void testgrid2_Load(object sender, EventArgs e)
        {
            gc1.ShowGroupDropArea = true;
            // gc1.DataSource = ds_activejobs;
            activeJobsTableAdapter.Fill(this.ds_activejobs.ActiveJobs);

            gc1.TableModel.ReadOnly = true;

            zoom = new ZoomGroupingGrid(gc1);

            // gc1.DataMember = ds_activejobs.ActiveJobs;

            Syncfusion.Grouping.SortColumnDescriptor cd = new Syncfusion.Grouping.SortColumnDescriptor("ShipDate");

            cd.Categorizer = new CustomCategorizer();
            this.gc1.TableDescriptor.GroupedColumns.Add(cd);
            //   this.gc1.QueryCellText += gc1_QueryCellText;

            //Summary Columns

            TestEntities db       = new TestEntities();
            DateTime     maxbatch = db.Batches.Max(p => p.BatchTime);


            lblTimeStamp.Text = "Data Accurate as of: " + maxbatch.ToString();

            #region summary columns

            gc1.TableDescriptor.VisibleColumns.Remove("ShipMonth");
            gc1.TableDescriptor.VisibleColumns.Remove("Batch");
            gc1.TableDescriptor.Columns["ShipDate"].Appearance.AnyRecordFieldCell.Format = "MM/dd/yyyy";

            gc1.TableDescriptor.Appearance.AnyRecordFieldCell.WrapText = true;

            gc1.TableModel.RowHeights.ResizeToFit(GridRangeInfo.Table());

            GridSummaryColumnDescriptor sc1 = new GridSummaryColumnDescriptor();
            sc1.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc1.DataMember  = "RemainingRev";
            sc1.Format      = "{Sum}";
            sc1.Name        = "Remaining Revenue";
            sc1.SummaryType = SummaryType.Int32Aggregate;



            GridSummaryColumnDescriptor sc2 = new GridSummaryColumnDescriptor();
            sc2.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc2.DataMember  = "POValue";
            sc2.Format      = "{Sum}";
            sc2.Name        = "Purchase Order Value";
            sc2.SummaryType = SummaryType.Int32Aggregate;


            //   sc2.TableDescriptor.Columns[0].Appearance.AnyRecordFieldCell.Format = "C";


            GridSummaryColumnDescriptor sc3 = new GridSummaryColumnDescriptor();
            sc3.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc3.DataMember  = "Actual";
            sc3.Format      = "{Sum}";
            sc3.Name        = "Actual";
            sc3.SummaryType = SummaryType.Int32Aggregate;

            sc1.Appearance.AnySummaryCell.Format = "c";
            sc2.Appearance.AnySummaryCell.Format = "c";
            sc3.Appearance.AnySummaryCell.Format = "c";

            GridSummaryColumnDescriptor sc4 = new GridSummaryColumnDescriptor();
            sc4.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc4.DataMember  = "Weld";
            sc4.Format      = "{Sum}";
            sc4.Name        = "Weld Hours Remaining";
            sc4.SummaryType = SummaryType.Int32Aggregate;

            GridSummaryColumnDescriptor sc5 = new GridSummaryColumnDescriptor();
            sc5.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc5.DataMember  = "Machine";
            sc5.Format      = "{Sum}";
            sc5.Name        = "Machine Hours Remaining";
            sc5.SummaryType = SummaryType.Int32Aggregate;

            GridSummaryColumnDescriptor sc6 = new GridSummaryColumnDescriptor();
            sc6.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc6.DataMember  = "Design";
            sc6.Format      = "{Sum}";
            sc6.Name        = "Design Hours Remaining";
            sc6.SummaryType = SummaryType.Int32Aggregate;

            GridSummaryColumnDescriptor sc7 = new GridSummaryColumnDescriptor();
            sc7.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc7.DataMember  = "Tracker";
            sc7.Format      = "{Sum}";
            sc7.Name        = "Tracker Hours Remaining";
            sc7.SummaryType = SummaryType.Int32Aggregate;

            GridSummaryColumnDescriptor sc8 = new GridSummaryColumnDescriptor();
            sc8.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(192, 255, 165));
            sc8.DataMember  = "Build";
            sc8.Format      = "{Sum}";
            sc8.Name        = "Build Hours Remaining";
            sc8.SummaryType = SummaryType.Int32Aggregate;


            GridSummaryRowDescriptor sr1 = new GridSummaryRowDescriptor();
            sr1.SummaryColumns.Add(sc1);
            sr1.SummaryColumns.Add(sc2);
            sr1.SummaryColumns.Add(sc3);
            sr1.SummaryColumns.Add(sc4);
            sr1.SummaryColumns.Add(sc5);
            sr1.SummaryColumns.Add(sc6);
            sr1.SummaryColumns.Add(sc7);
            sr1.SummaryColumns.Add(sc8);

            gc1.Appearance.AnySummaryCell.HorizontalAlignment = GridHorizontalAlignment.Right;

            sr1.Appearance.AnySummaryCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(255, 231, 162));

            gc1.TableDescriptor.SummaryRows.Add(sr1);

            #endregion


            //   gc1.TableControl.PrepareViewStyleInfo += new;

            gc1.TableControl.CommentTipShowing += new CommentTipShowingEventHandler(TableControl_CommentTipShowing);



            //GridConditionalFormatDescriptor f1 = new GridConditionalFormatDescriptor();
            f1.Appearance.AnyRecordFieldCell.Interior  = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(220, 20, 60));
            f1.Appearance.AnyRecordFieldCell.TextColor = Color.White;
            f1.Expression = "[age1] > 10 and [Comp] < 20";
            f1.Name       = "Format1";

            //GridConditionalFormatDescriptor f2 = new GridConditionalFormatDescriptor();
            f2.Appearance.AnyRecordFieldCell.Interior  = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(30, 144, 255));
            f2.Appearance.AnyRecordFieldCell.TextColor = Color.White;
            f2.Expression = "[age1] < 10";
            f2.Name       = "Format2";

            gc1.TableDescriptor.ConditionalFormats.Add(f1);
            gc1.TableDescriptor.ConditionalFormats.Add(f2);

            gc1.QueryCellStyleInfo             += new GridTableCellStyleInfoEventHandler(gc1_QueryCellStyleInfo);
            gc1.SourceListListChangedCompleted += Gc1_SourceListListChangedCompleted;

            GridColumnDescriptor desc1 = new GridColumnDescriptor();

            desc1.MappingName = "BaseID";
            desc1.Appearance.AnyRecordFieldCell.Interior = new Syncfusion.Drawing.BrushInfo(Color.FromArgb(237, 240, 246));

            gc1.TableControl.HScroll = true;
            gc1.TableControl.VScroll = true;

            if (gc1.TableControl.HScrollBar.InnerScrollBar != null && gc1.TableControl.VScrollBar != null)
            {
                gc1.TableControl.HScrollBar.InnerScrollBar.Height = 50;
                gc1.TableControl.VScrollBar.InnerScrollBar.Height = 50;
            }


            gc1.TableControl.ControlAdded += TableControl_ControlAdded;
        }