I have successfully implemented column groups in my wingrid via the row layouts. Now that I've done that, I need to freeze the first group (containing the first two data columns) so as I scroll horizontally that group stays put.
I've tried everything I can think of based on what I've found in your forum, but nothing seems to work. Since I have three grouped headings, I had to create two groups for the first two columns. One is the parent of the other. The groups are named GC_Empty and Empty and contain data columns 1 and 2 (column 0 is hidden). So I assumed that I would do one of the following (or both)
1. GC_Empty.Header.Fixed = true;
Empty.Header.Fixed = true;
2. band.Columns[1].Header.Fixed = true;
band.Columns[2].Header.Fixed = true;
Then afterwards: ugManagers.DisplayLayout.Override.FixedCellSeparatorColor = Color.Red;
Thanks in advance,
Paul
Hi,
ColScrollRegions are the old way to do it. We added true fixed header support a few years back. All you have to so is set UseFixedheaders to true and then you can set the Fixed property on the Group Header to true to fix a group. By default, the user can change the fixed state of a group, but you can turn this off by setting FixedHeaderIndicator to None. In fact, that was the original usage in the first post in this thread. :)
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridOverride ov = layout.Override; layout.UseFixedHeaders = true; ov.FixedHeaderIndicator = FixedHeaderIndicator.None; band.Groups[0].Header.Fixed = true; }
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
{
UltraGridLayout layout = e.Layout;
UltraGridBand band = layout.Bands[0];
UltraGridOverride ov = layout.Override;
layout.UseFixedHeaders = true;
ov.FixedHeaderIndicator = FixedHeaderIndicator.None;
band.Groups[0].Header.Fixed = true;
}
Anyway, just to double check, I tried creating a small sample project with a grid with two ColScrollRegions and a column set to ExclusiveColScrollRegion on the first one and then I exported it to Excel. Like I thought, the ColScrollRegions have no effect on exporting.
I think there might have been a bug where this used to happen, but it was fixed a really long time ago. Are you using a very old version of the controls?
If that is the case, you could work around it by just removing the ColScrollRegion stuff from the export layout:
private void ultraGridExcelExporter1_ExportStarted(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.ExportStartedEventArgs e) { foreach (UltraGridBand band in e.Layout.Bands) { foreach (UltraGridGroup group in band.Groups) { group.Header.ResetExclusiveColScrollRegion(); } foreach (UltraGridColumn column in band.Columns) { column.Header.ResetExclusiveColScrollRegion(); } } e.Layout.ColScrollRegions.Clear(); }
private void ultraGridExcelExporter1_ExportStarted(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.ExportStartedEventArgs e)
foreach (UltraGridBand band in e.Layout.Bands)
foreach (UltraGridGroup group in band.Groups)
group.Header.ResetExclusiveColScrollRegion();
foreach (UltraGridColumn column in band.Columns)
column.Header.ResetExclusiveColScrollRegion();
e.Layout.ColScrollRegions.Clear();
There isn't any column hiding. Before I did the scroll regions, I was able to do the export and get all the columns. now I only get the first one. I am forcing the first column to be exclusive to the first scroll region, maybe that's where the problem is?
I was under the impression that the only way to allow for scrolling such that the first x number of columns would stay stationary was by way of scrolling regions.
Hi Paul,
ColScrollRegions should never have any effect on exporting. Are you sure it's the ColScrollRegions that are causing this and not something else in your application? Maybe you are hiding the column in the other scroll regions for some reason?
BTW... if you are no longer using RowLayouts, why use ColScrollRegions? Fixed Headers are probably better, anyway.
You're right --- that was easy. Couldn't find anything related to that on the various documentation pages, though. Thankfully you knew about it.
I have one more issue. Now that I have scroll regions defined, one of the pieces of functionality that we have on our usage of WinGrid, is the ability to right-click on the grid and perform an "Export to Excel". The underlying code simply runs the following:
private Infragistics.Win.UltraWinGrid.ExcelExport.UltraGridExcelExporter ugExcelExporter;
string fileName = directoryName + "\\Temp" + System.DateTime.Now.Ticks + ".xls";
ugExcelExporter.Export(this, fileName);
System.Diagnostics.Process.Start(fileName);
The problem is alll we get in our exported document is the first scroll region column. I know that the exporting function worked before I added the scroll regions, so there might be something we have to do to make the export work right when there are scrolling regions...
That's an easy one:
layout.ColScrollRegions[0].SizingMode = SizingMode.Fixed;