Hello,
Can i add 2 footer caption to differentiate Average and summary? Check the below example
Charge Type
Charge 1
Charge 2
Charge 3
AAA
10
20
30
BBB
CCC
DDD
Average
Summary
40
80
120
if i can, can i get sample code for this?
Thanks,
Mayank
Hello Mayank,
Maybe you could try the code below:
ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Average, ultraGrid1.DisplayLayout.Bands[0].Columns["Charge 1"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Sum, ultraGrid1.DisplayLayout.Bands[0].Columns["Charge 1"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Average, ultraGrid1.DisplayLayout.Bands[0].Columns["Charge 2"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Sum, ultraGrid1.DisplayLayout.Bands[0].Columns["Charge 2"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Average, ultraGrid1.DisplayLayout.Bands[0].Columns["Charge 3"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(Infragistics.Win.UltraWinGrid.SummaryType.Sum, ultraGrid1.DisplayLayout.Bands[0].Columns["Charge 3"], Infragistics.Win.UltraWinGrid.SummaryPosition.UseSummaryPositionColumn);
Please take a look on attached sample for more details and if you have any questions, feel free to write me
Regards
Sample :
Thanks for replying me Georgi. I already did this. However i wanted summary different way. As i showed you in my example, i want one row (FooterCaption) as Average and another row as Sum. I do not want Average, Sum associated in each every average,sum column.
Check the example grid as i showed you.
Can i do that?
Hi,
There are different approaches to solve this task. If you want you could implement CreationFIlter. Another possible solution (without CreationFilter ) could be:
public Form1()
{
InitializeComponent();
DataTable dt = new DataTable();
dt.Columns.Add("ChargeType", typeof(string));
dt.Columns.Add("Charge 1", typeof(decimal));
dt.Columns.Add("Charge 2", typeof(decimal));
dt.Columns.Add("Charge 3", typeof(decimal));
dt.Rows.Add("AAA", 10, 20, 30);
dt.Rows.Add("BBB", 10, 20, 30);
dt.Rows.Add("CCC", 10, 20, 30);
dt.Rows.Add("DDD", 10, 20, 30);
ultraGrid1.DataSource = dt;
ultraGrid1.DisplayLayout.Bands[0].SummaryFooterCaption = "Average";
ultraGrid1.DisplayLayout.Bands[0].Summaries[1].Appearance.BackColor = Color.White;
ultraGrid1.DisplayLayout.Bands[0].Summaries[1].DisplayFormat = "Summary";
ultraGrid1.DisplayLayout.Bands[0].Summaries[4].Appearance.BackColor = Color.White;
ultraGrid1.DisplayLayout.Bands[0].Summaries[4].DisplayFormat = " ";
ultraGrid1.DisplayLayout.Bands[0].Summaries[7].Appearance.BackColor = Color.White;
ultraGrid1.DisplayLayout.Bands[0].Summaries[7].DisplayFormat = " ";
}
private void ultraGrid1_Paint(object sender, PaintEventArgs e)
SummaryValueUIElement a = ultraGrid1.DisplayLayout.UIElement.GetDescendant(typeof(SummaryValueUIElement), ultraGrid1.DisplayLayout.Bands[0].Summaries[1]) as SummaryValueUIElement;
if (a != null)
a.Offset(-133, 0);
[/code]
Let me know if you have any questions
The only problem with this when you move Charge 1 column it will move label(Display Format = "Summary") with the column. Average would stay there because it is a footer caption.
I made small modifications in the code. Please try :
a.Rect = new Rectangle(a.Parent.Rect.X, a.Rect.Y,a.Rect.Width, a.Rect.Height);
ultraGrid1.Invalidate();
Also, please note that you should set :
ultraGrid1.DisplayLayout.Bands[0].Summaries[1].Appearance.TextHAlign = Infragistics.Win.HAlign.Left;
Let me know if you have any questions.
Thanks Gerogi.
It works the way i wanted. :)
thanks for ur reply!!!
but unfortunately it doesn't work.
it does not move the focus from the last of the current group to the first row of the next group.