Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1871
How to create a default grid that can be maintained?
posted

All of our grids have default display layout settings. As you know not all grids are created equal so the developer may need to change certain aspects of it. I tried creating a user control that could be dragged and dropped but the problem is it can only be maintained at the code level. The developer needs to see the changes at design time.

I created a grid overrides but it only works at the code level. The changes happen after the grid has been initialized.

        private void GridOverrides()
        {
            this.ultraGrid1.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.ultraGrid1.DisplayLayout.Appearance.BackColor = System.Drawing.SystemColors.Window;
            this.ultraGrid1.DisplayLayout.AutoFitStyle = AutoFitStyle.ExtendLastColumn;
            this.ultraGrid1.DisplayLayout.Appearance.BorderColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.BorderStyle = UIElementBorderStyle.Default;
            this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = SelectType.Single;
            this.ultraGrid1.DisplayLayout.Override.AllowDelete = DefaultableBoolean.False;
            this.ultraGrid1.DisplayLayout.CaptionVisible = DefaultableBoolean.False;
            this.ultraGrid1.DisplayLayout.MaxColScrollRegions = 1;
            this.ultraGrid1.DisplayLayout.MaxRowScrollRegions = 1;
            this.ultraGrid1.DisplayLayout.NewColumnLoadStyle = NewColumnLoadStyle.Hide;
            this.ultraGrid1.DisplayLayout.ScrollBounds = ScrollBounds.ScrollToFill;
            this.ultraGrid1.DisplayLayout.ScrollStyle = ScrollStyle.Immediate;
            this.ultraGrid1.DisplayLayout.ViewStyle = ViewStyle.SingleBand;
            this.ultraGrid1.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;

            // Active Cell Overrides
            this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.BackColor = System.Drawing.SystemColors.Window;
            this.ultraGrid1.DisplayLayout.Override.ActiveCellAppearance.ForeColor = System.Drawing.Color.Empty;

            // Active Row Overrides
            this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.BackColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.ActiveRowAppearance.ForeColor = System.Drawing.Color.Empty;

            // Column Overrides
            this.ultraGrid1.DisplayLayout.Override.AllowColMoving = AllowColMoving.WithinGroup;
            this.ultraGrid1.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.True;
            this.ultraGrid1.DisplayLayout.Override.ColumnSizingArea = ColumnSizingArea.EntireColumn;
            this.ultraGrid1.DisplayLayout.Override.FixedRowIndicator = FixedRowIndicator.Button;
            this.ultraGrid1.DisplayLayout.Override.GroupByColumnsHidden = DefaultableBoolean.True;

            // Cell Appearance Overrides
            this.ultraGrid1.DisplayLayout.Override.BorderStyleCell = UIElementBorderStyle.Default;
            this.ultraGrid1.DisplayLayout.Override.CellAppearance.BorderColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.CellAppearance.TextHAlign = HAlign.Left;
            this.ultraGrid1.DisplayLayout.Override.CellAppearance.TextTrimming = TextTrimming.EllipsisCharacter;
            this.ultraGrid1.DisplayLayout.Override.CellAppearance.TextVAlign = VAlign.Default;
            this.ultraGrid1.DisplayLayout.Override.CellClickAction = CellClickAction.RowSelect;
            this.ultraGrid1.DisplayLayout.Override.CellMultiLine = DefaultableBoolean.True;
            this.ultraGrid1.DisplayLayout.Override.CellPadding = -1;

            // Card Appearance Overrides
            this.ultraGrid1.DisplayLayout.Override.CardAreaAppearance.BackColor = System.Drawing.SystemColors.Window;

            // Row Overrides
            this.ultraGrid1.DisplayLayout.Override.BorderStyleRow = UIElementBorderStyle.Default;
            this.ultraGrid1.DisplayLayout.Override.DefaultRowHeight = -1;
            this.ultraGrid1.DisplayLayout.Override.RowAppearance.BackColor = System.Drawing.SystemColors.Window;
            this.ultraGrid1.DisplayLayout.Override.RowAppearance.BorderColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.RowSizing = RowSizing.AutoFree;
            this.ultraGrid1.DisplayLayout.Override.RowSizingArea = RowSizingArea.EntireRow;
            this.ultraGrid1.DisplayLayout.Override.RowSelectors = DefaultableBoolean.True;
            this.ultraGrid1.DisplayLayout.Override.SelectTypeRow = SelectType.Single;

            // Header
            this.ultraGrid1.DisplayLayout.Override.HeaderAppearance.TextHAlign = HAlign.Left;
            this.ultraGrid1.DisplayLayout.Override.HeaderAppearance.TextVAlign = VAlign.Default;
            this.ultraGrid1.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.SortMulti;
            this.ultraGrid1.DisplayLayout.Override.HeaderStyle = HeaderStyle.Default;
            this.ultraGrid1.DisplayLayout.Override.RowSelectorHeaderStyle = RowSelectorHeaderStyle.ColumnChooserButton;
            this.ultraGrid1.DisplayLayout.Override.WrapHeaderText = DefaultableBoolean.True;

            // Group By Row Appearance
            this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance.BackColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance.BackColor2 = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance.BackGradientAlignment = GradientAlignment.Default;
            this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance.BackGradientStyle = GradientStyle.Default;
            this.ultraGrid1.DisplayLayout.Override.GroupByRowAppearance.BorderColor = System.Drawing.Color.Empty;

            // Special Row Appearance
            this.ultraGrid1.DisplayLayout.Override.SpecialRowSeparator = SpecialRowSeparator.SummaryRow;
            this.ultraGrid1.DisplayLayout.Override.SpecialRowSeparatorAppearance.BorderColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.SpecialRowSeparatorHeight = -1;

            // Summary Value Appearance
            this.ultraGrid1.DisplayLayout.Override.SummaryDisplayArea = (Infragistics.Win.UltraWinGrid.SummaryDisplayAreas)(Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.TopFixed | Infragistics.Win.UltraWinGrid.SummaryDisplayAreas.InGroupByRows);
            this.ultraGrid1.DisplayLayout.Override.GroupBySummaryDisplayStyle = GroupBySummaryDisplayStyle.SummaryCells;
            this.ultraGrid1.DisplayLayout.Override.SummaryValueAppearance.BorderColor = System.Drawing.Color.Empty;
            this.ultraGrid1.DisplayLayout.Override.SummaryValueAppearance.TextVAlign = VAlign.Default;
            this.ultraGrid1.DisplayLayout.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;

            // Set Alternate and Summary Row Color
            if (Options.CustomizeOptions.OverrideDefaultRowColors)
            {
                this.ultraGrid1.DisplayLayout.Override.RowAlternateAppearance.BackColor = Options.CustomizeOptions.AlternateRowColor;
                this.ultraGrid1.DisplayLayout.Override.SummaryValueAppearance.BackColor = Options.CustomizeOptions.SummaryRowColor;
            }
        }

Any ideas how I can create or import a default display layout?

Parents
  • 53790
    Verified Answer
    posted

    Hello Michael,

    There are different approaches to solve this task. One possible solution to export the layout from one grid and import into another grid, could be through Grid`s LayoutWizard. Select a grid, then from context menu, you could run the LayoutWizard. Follow the steps in the wizard to export or import your layout.

    Also you could use both methods to save and load the layouts from files. For example:

    ultraGrid1.DisplayLayout.SaveAsXml()

    ultraGrid1.DisplayLayout.LoadFromXml()

     

    Of course you could use approach with UserControls that contains public property (for example of UltraGrid type). By this way you will have access at design time to modify settings.

    The third approach could be with inheritance. You could create a class that inherit our UltraGrid.

    Let me know if you have any questions.

    Regards

     

Reply Children
No Data