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[
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
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); }
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;
layout.ColScrollRegions.Clear();
layout.MaxColScrollRegions = 2;
if ( fixedWidth < ultraGrid1.Width )
{ layout.ColScrollRegions[0].Split(fixedWidth); layout.ColScrollRegions[0].Scrollbar =
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); }
Hi Ivan,
Sorry for the confusion. You can fix groups, but only in the standard mode, not in RowLayout mode.
In your last comment, you seem to imply that I could fix the columns via grouping which is why I asked.
I'll look into ColScrollRegion.
Thx,
Ivan
digitalwraith said:So how do you do it? I have 2 groups. I'd like to freeze one group( the first 4 columns) but that functionailty seems to conflict with using RowLayoutInfo to manage my column headers.
That's correct. RowLayouts and Fixed Header are mutually exclusive features. You cannot fix coumns or groups when using RowLayouts.
Perhaps you could use a ColScrollRegion, instead?
So how do you do it? I have 2 groups. I'd like to freeze one group( the first 4 columns) but that functionailty seems to conflict with using RowLayoutInfo to manage my column headers. Below is a pic of the header structure I want. The second pic shows the groups that I want. Notice the only run-time difference is the selection state of the Use Row Layout checkbox. I have seen hints and implications that this can be done, but no sample code. I can provide code for my example if it would help sort all of this out. Thx!
Pic 1: UseRowLayout = true; Column headers "stacked" a "visual" groups.
Pic 2: UseRowLayout = false; Columns correctly frozen, but lost the headers.