Hi there,
I tried to provide some project-wide design presets via the Layout Manager but unfortunately some basic properties are not stored in the *.lyt-file. So I created a helper method that sets some appearances and properties to fit my project's needs (it's just like the designer generated code).
So my question is, where do I have to place code like this:
ultraWinGrid.DisplayLayout.Appearance = appearance1; ultraWinGrid.DisplayLayout.AutoFitStyle = Infragistics.Win.UltraWinGrid.AutoFitStyle.ResizeAllColumns; ultraWinGrid.DisplayLayout.CaptionVisible = Infragistics.Win.DefaultableBoolean.False; ultraWinGrid.DisplayLayout.GroupByBox.Hidden = true; ultraWinGrid.DisplayLayout.InterBandSpacing = 10; ultraWinGrid.DisplayLayout.Override.AllowAddNew = Infragistics.Win.UltraWinGrid.AllowAddNew.No; ultraWinGrid.DisplayLayout.Override.AllowDelete = Infragistics.Win.DefaultableBoolean.False; ultraWinGrid.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.True; ultraWinGrid.DisplayLayout.Override.AllowUpdate = Infragistics.Win.DefaultableBoolean.False; ultraWinGrid.DisplayLayout.Override.CardAreaAppearance = appearance2; ultraWinGrid.DisplayLayout.Override.CellClickAction = Infragistics.Win.UltraWinGrid.CellClickAction.RowSelect; ultraWinGrid.DisplayLayout.Override.FilterUIType = Infragistics.Win.UltraWinGrid.FilterUIType.HeaderIcons; ultraWinGrid.DisplayLayout.Override.HeaderAppearance = appearance3; ultraWinGrid.DisplayLayout.Override.HeaderClickAction = Infragistics.Win.UltraWinGrid.HeaderClickAction.SortMulti; ultraWinGrid.DisplayLayout.Override.RowAlternateAppearance = appearance4; ultraWinGrid.DisplayLayout.Override.RowAppearance = appearance5; ultraWinGrid.DisplayLayout.Override.RowSelectorAppearance = appearance6; ultraWinGrid.DisplayLayout.Override.RowSelectors = Infragistics.Win.DefaultableBoolean.False; ultraWinGrid.DisplayLayout.Override.RowSelectorWidth = 12; ultraWinGrid.DisplayLayout.Override.RowSpacingBefore = 0; ultraWinGrid.DisplayLayout.Override.SelectedRowAppearance = appearance7; ultraWinGrid.DisplayLayout.Override.SelectTypeCell = Infragistics.Win.UltraWinGrid.SelectType.None; ultraWinGrid.DisplayLayout.Override.SelectTypeCol = Infragistics.Win.UltraWinGrid.SelectType.None; ultraWinGrid.DisplayLayout.Override.SelectTypeGroupByRow = Infragistics.Win.UltraWinGrid.SelectType.None; ultraWinGrid.DisplayLayout.Override.SelectTypeRow = Infragistics.Win.UltraWinGrid.SelectType.Extended; ultraWinGrid.DisplayLayout.RowConnectorColor = System.Drawing.Color.FromArgb(((int)(((byte)(170)))), ((int)(((byte)(184)))), ((int)(((byte)(131))))); ultraWinGrid.DisplayLayout.ScrollStyle = Infragistics.Win.UltraWinGrid.ScrollStyle.Immediate; ultraWinGrid.DisplayLayout.TabNavigation = Infragistics.Win.UltraWinGrid.TabNavigation.NextControlOnLastCell; ultraWinGrid.DisplayLayout.ViewStyle = Infragistics.Win.UltraWinGrid.ViewStyle.SingleBand; ultraWinGrid.DisplayLayout.ViewStyleBand = Infragistics.Win.UltraWinGrid.ViewStyleBand.OutlookGroupBy; ultraWinGrid.Font = new System.Drawing.Font("Trebuchet MS", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
For any help, thanks in advance.
- Achim
Hi again,
thanks for your answers. I think both solutions would work - and I found the third one: I found out how to set all my desired properties (in my case it was the font of the column headers) within the DisplayLayout object. So it could be stored in the lyt-File using the layout wizard.
I provide a helper method that loads an embedded lyt-File and applies it at InitializeLayout to the grid. This works fine for me and my team.
Do you think this solution is ok?
PS: I think I have found a bug in the layout wizard. The wizard loads and saves all categories regardless what I have selected.
moojoo said: I provide a helper method that loads an embedded lyt-File and applies it at InitializeLayout to the grid. This works fine for me and my team. Do you think this solution is ok?
A Layout will only work if all of the grids you are using around bound to exactly the same data structure. If you are using grids that load up different bands or columns, then the layout will not load into a grid that does not match the structure for which it was saved.
A preset is independent of the data structure.
moojoo said:PS: I think I have found a bug in the layout wizard. The wizard loads and saves all categories regardless what I have selected.
Some property categories have prerequisites of other categories. So I suspect it's not saving or loading everything, but it's saving more than expect because you are specifying a category that need other categories. For example, you cannot save/load the filtering without also saving/load the columns.
Hi,
Just to follow up, I just tested the Layout Wizard by doing the following:
This worked fine for me. The GroupByBox on the grid and all of the default preset appearances came back, but the column widths, grouping, and sorting were all reset to their defaults.
Hi Achim,
If you are saving using General, and the grouping and unbound columns are getting saved and loaded, then that's a bug. General includes things like the AddNewBox, the GroupByBox, and Appearances only.
But... the Layout of the grid is specifically designed to hold all of the user-customizable features of the grid like column position, sizing, grouping, sorting, etc. It saves some other things, too, but that's really the main purpose. That way, you can store, and restore, the same settings the user had the last time they closed the application.
All of the settings you are trying to save here are things the user cannot modify, like appearances. So a Preset makes more sense in this case.
Also, as I said, the preset is independent of the data structure, so you can load a preset into any grid, regardless of it's data source. A Layout will fail to load into any grid whose data structure does not precisely match the one for which it was saved.
Hi Mike,
i'm using the following code to load only the general settings which obviously do not include the column structure:
//INFO: We only load general settings because we only want the design settings //grouping, unbound columns etc. should be done in user code grid.DisplayLayout.Load(resourceStream, PropertyCategories.General);