I am trying to add a total at the bottom of a sale amount column. I get the following exception on the last line of my code that adds the summary for that column. I can't figure out why. I want the summary to have a currency style for that column.
=== CODE ===
With e.Layout .AutoFitStyle = AutoFitStyle.ExtendLastColumn .Scrollbars = Scrollbars.Automatic .ViewStyle = ViewStyle.SingleBand .Override.CellPadding = 3 .Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Solid .Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Solid .Override.CellAppearance.BorderColor = Color.Black .Override.RowAppearance.BorderColor = Color.Black .Override.CellClickAction = CellClickAction.EditAndSelectText .Bands(0).Columns("saleamount").AllowRowSummaries = AllowRowSummaries.True .Bands(0).Summaries.Add("saletotal", SummaryType.Sum, .Bands(0).Columns("saleamount"), SummaryPosition.UseSummaryPositionColumn) .Bands(0).Summaries(0).SummaryDisplayArea = SummaryDisplayAreas.BottomFixed .Bands(0).Summaries(0).DisplayFormat = "{0}" .Bands(0).Summaries(0).Appearance.BackColor = Color.White .Bands(0).Summaries(0).SummaryPositionColumn.Style = ColumnStyle.Currency <-- exception thrown here
End With
=== exception thrown ===
System.NullReferenceException was unhandled Message="Object reference not set to an instance of an object." StackTrace: at frmOptionsDialog.grdOptions_InitializeLayout(Object sender, InitializeLayoutEventArgs e) at Infragistics.Win.UltraWinGrid.UltraGrid.OnInitializeLayout(InitializeLayoutEventArgs e)
The secret of the format is in the summary DisplayFormat. Try this block of code out:
With e.Layout .AutoFitStyle = AutoFitStyle.ExtendLastColumn .Scrollbars = Scrollbars.Automatic .ViewStyle = ViewStyle.SingleBand .Override.CellPadding = 3 .Override.BorderStyleCell = Infragistics.Win.UIElementBorderStyle.Solid .Override.BorderStyleRow = Infragistics.Win.UIElementBorderStyle.Solid .Override.CellAppearance.BorderColor = Color.Black .Override.RowAppearance.BorderColor = Color.Black .Override.CellClickAction = CellClickAction.EditAndSelectText .Bands(0).Columns("saleamount").AllowRowSummaries = AllowRowSummaries.True .Bands(0).Summaries.Add("saletotal", SummaryType.Sum, .Bands(0).Columns("saleamount"), SummaryPosition.UseSummaryPositionColumn) .Bands(0).Summaries(0).SummaryDisplayArea = SummaryDisplayAreas.BottomFixed .Bands(0).Summaries(0).DisplayFormat = "{0:$ #######.00}" .Bands(0).Summaries(0).Appearance.BackColor = Color.White End With
I'm not sure why you are getting that Exception. When the exception occurs, what object is null?
In any case, Torrey is correct. Setting the Style on column won't do anything to the summary, anyway, it will only affect the column itself.
Is there a way to set the .CellPadding for the summary? I can't find it. I am setting the CellPadding for my data, but can't get the same look for the summary.
e.Layout.Override.CellPadding = 3
No, I don't think summaries support CellPadding, although I would think it would pick up the CellPadding that the column is using so that it looks consistent - at least horizontally. Is that not the case?
Hi,
Yes, this was considered to be a bug and was fixed in NetAdvantage 2010 Vol. 3. The summary cells now honor the cell padding from the SummaryPositionColumn (the column to which the summary is aligned), if there is one.
Hi Mike,
has this bug been resolved by Infragistics? we are using version 7.2 and the problem still exists. What is the alternative as my text field is left aligned while numbers are right aligned. So i definitely need some padding in summary rows.
So the cells are padded and the summaries are showing up unpadded and therefore are not properly aligned to the cells in the column? If that's true, I'd say it's a bug and you should Submit an incident to Infragistics Developer Support
No, that is not the case.