Hi, I am looking for sample code that create a summary row of an UltraGrid. I am learning C#, please help.
Thanks,
Hi,
I'm sure there are sample of this in the WinGrid Samples Explorer that installed with the NetAdantage SDK.
Basically, the best place to do this is in the InitializeLayout event. A very simply exmaple would look something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { e.Layout.Bands[0].Summaries.Add(SummaryType.Sum, e.Layout.Bands[0].Columns["My Grid Column"]); }
how to Get Two Bands value in UltraWinGrid
UltraGrid.DisplayLayout.Bands[0]
UltraGrid.DisplayLayout.Bands[1]
this two bands Summaries value how ll get using Query
To get the value of a summary, you can't use the band, you have to get it from a Rows collection. So, for the root band, you would do something like this:
this.ultraGrid1.Rows.SummaryValues[summaryKeyorIndex].Value
There's no way to get a summary for a child band, because there are no summaries for child bands. Once again, the summary is a summary of a rows collection. So you would have to get a reference to the particular rows collection you want and use the SummaryValues collection on that. How you get the rows depends on which rows you want.
Hi Mike,
I have a project with using UltraWinGrid.
I want to add 1 Summary of a Column by dividing 2 available Summaries of 2 different columns in UltraWinGrid.
Can you help me.
Thank you.
I can't make heads or tails of that screen shot. But it sounds like you want a summary whose value is calculated based on two other summaries. Is that right?
If so, there are several ways to achieve that. The simplest way is to use an "external" summary. This is a relative new feature, though, so if you are using an older version of the grid, you might not have it.
Something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; band.Summaries.Add("Sum 1", SummaryType.Sum, band.Columns["Int32 1"]); band.Summaries.Add("Sum 2", SummaryType.Sum, band.Columns["Int32 2"]); band.Summaries.Add("Combined Sum", SummaryType.External, band.Columns["string 1"]); } void ultraGrid1_ExternalSummaryValueRequested(object sender, ExternalSummaryValueEventArgs e) { if (e.SummaryValue.Key == "Combined Sum") { RowsCollection rows = e.SummaryValue.ParentRows; int sum1 = (int)((decimal)(rows.SummaryValues["Sum 1"].Value)); int sum2 = (int)((decimal)rows.SummaryValues["Sum 2"].Value); e.SummaryValue.SetExternalSummaryValue(sum1 + sum2); } }
If you have an older version before External Summaries were added, the you would have to use either an ICustomSummaryCalculator or else a formula (which would mean adding an UltraCalcManager to the form).
Thanks for your help, code works very well with my project.
If I use ICustomSummaryCalculator, how i can adding an UltraCalcManager, I tried many way to add....but no way to add.
ICustomSummaryCalculator and UltraCalcManager are two totally different approaches. You certainly don't need both.
UltraCalcManager is a component. You add it to the form from the toolbox like you would any other component or control.
But really, the external summary is the easiest way to go.
Thanks for your help.