Ejemplo 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));
        }
Ejemplo n.º 2
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;
            }
        }
Ejemplo n.º 3
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;
            }
        }
Ejemplo n.º 4
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");
        }
Ejemplo n.º 5
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
        }
Ejemplo n.º 6
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;
            }
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
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;
            }
        }
Ejemplo n.º 9
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;
        }