Hi there,
I'm using a ultrawingrid in one of my windows project and what's I'm trying to do is to be abled to freeze the fist two columns of the grid on a horizontal scroll. I use the following code :
e.Layout.Bands[0].Columns["hrpd_iNo"].Header.Fixed = true;
e.Layout.Bands[0].Columns["bxpd_xDesc"].Header.Fixed = true;
This code works only if I set the ultragridband's UseRowLayout property to false.
1) Is there a way to make this code works even if the UserRowLayout property is true?
2) I'm trying to export the same grid to EXCEL by using UltragridExcelExporter object; and my app juste freeze in the export() method.... Is it because I'm using the RowLayout in my grid also?
Thanks for your help,
Seraphin
umeninnovation said:1) Is there a way to make this code works even if the UserRowLayout property is true?
No. RowLayouts and Fixed headers are mutually exclusive. You can Submit a feature request to Infragistics
umeninnovation said:2) I'm trying to export the same grid to EXCEL by using UltragridExcelExporter object; and my app juste freeze in the export() method.... Is it because I'm using the RowLayout in my grid also?
No, you can export a grid using a RowLayout, that should not be a problem. I don't know why it's freezing on you. Are you using the latest Hot Fix? Can you duplicate the problem in a small sample project?
What if you have two fields in a group? Can you make the group fixed?
Below is the code I ended up using. A "node" is basically a column definition from a content perspective without regard for what is in the grid. A node without a parent or child is one of my "fixedNodes".
One interesting bug shows up when the split isn't visible, as in the fixed width is larger than the width of the grid. The app throws an exception when that occurs, so I had to write a simple check before implementing the split.
Enjoy,Ivan
private
void FreezeColumns()
{
List<int> fixedNodes = DataFormat.AllNodes.Where(i => i.ListLength == 1).Select(i => i.LeftLowestChildIndex).ToList();
UltraGridLayout layout = ultraGrid1.DisplayLayout;
UltraGridBand band = layout.Bands[0];
int fixedWidth = band.Columns.Cast<UltraGridColumn>().Where(i => fixedNodes.Contains(i.Index)).Sum(i => i.Width) - 1;
layout.ColScrollRegions.Clear();
layout.MaxColScrollRegions = 2;
if ( fixedWidth < ultraGrid1.Width )
layout.ColScrollRegions[0].Split(fixedWidth);
layout.ColScrollRegions[0].Scrollbar =
Scrollbar.Hide;
}
else
layout.ColScrollRegions[0].Split();
layout.ColScrollRegions[1].ScrollHeaderIntoView(band.Columns[fixedNodes.Max(i => i) + 1].Header,
true);
Ivan,
Thanks for that code snippet. I copied it into my code but got an error on the reference for DataFormat and 'band.Columns.Cast<UltraGridColumn>()'.
Hopefully this post is still active. Thanks in advance, Paul
What were the errors?
For the DataFormat: "The name 'DataFormat' does not exist in the current context"
And for: band.Columns.Cast<UltraGridColumn>()
Error 26 'Infragistics.Win.UltraWinGrid.ColumnsCollection' does not contain a definition for 'Cast' and the best extension method overload 'System.Data.EnumerableRowCollectionExtensions.Cast<TResult>(System.Data.EnumerableRowCollection)'...
My guess is that you are using CLR2 and these are new language features in CLR3/CLR4.