Hi,
I have a grid with 3 aggregate footers, when the user groups on a particular column I’m adding
the aggregate values to the group
header, which works fine.
But I cannot get the text to align , I have tried to pad the
text with spaced with no success, here an image…
What I’m hoping to do is basically align / give the illusion
of 4 columns in the header, one for the column title the other 3 for each aggregate value.
Here's some code:
private void gviTicketSummary_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
{
int i = 0;
if (e.SummaryItem == null)
return;
if (e.SummaryItem.Name == "Site")
{
int count = e.Group.ItemCount;
decimal PlannedQty = 0;
decimal ActualQty = 0;
foreach (GridViewRowInfo row in e.Group)
{
PlannedQty += Convert.ToDecimal(row.Cells["PlannedQty"].Value);
ActualQty += Convert.ToDecimal(row.Cells["ActualQty"].Value);
}
string sPlanned = PlannedQty.ToString("#,##0");
string sPlannedNew = PlannedQty.ToString("#,##0");
if (sPlanned.Length < 20)
sPlannedNew = sPlanned.PadRight(20, ' ');
string sActual = ActualQty.ToString("#,##0");
string sActualNew = ActualQty.ToString("#,##0");
if (sActual.Length < 20)
sActualNew = sActual.PadRight(20, ' ');
string site = e.Value.ToString().Trim();
string siteNew;
if (site.Length < 20)
{
siteNew = site.PadRight(20, ' ');
}
else
siteNew = site;
string Header = string.Concat(siteNew, " Planned Tonnes :", sPlannedNew, "Actual Tonnes : ", sActualNew);
// e.FormatString = String.Format("{0}Planned Tonnes : {1} Actual Tonnes : {2}", siteNew, sPlannedNew, sActualNew);
e.FormatString = Header;
}
}
Hope this makes sense
Thanks
Shaun
I have a grid with 3 aggregate footers, when the user groups on a particular column I’m adding
the aggregate values to the group
header, which works fine.
But I cannot get the text to align , I have tried to pad the
text with spaced with no success, here an image…
What I’m hoping to do is basically align / give the illusion
of 4 columns in the header, one for the column title the other 3 for each aggregate value.
Here's some code:
private void gviTicketSummary_GroupSummaryEvaluate(object sender, GroupSummaryEvaluationEventArgs e)
{
int i = 0;
if (e.SummaryItem == null)
return;
if (e.SummaryItem.Name == "Site")
{
int count = e.Group.ItemCount;
decimal PlannedQty = 0;
decimal ActualQty = 0;
foreach (GridViewRowInfo row in e.Group)
{
PlannedQty += Convert.ToDecimal(row.Cells["PlannedQty"].Value);
ActualQty += Convert.ToDecimal(row.Cells["ActualQty"].Value);
}
string sPlanned = PlannedQty.ToString("#,##0");
string sPlannedNew = PlannedQty.ToString("#,##0");
if (sPlanned.Length < 20)
sPlannedNew = sPlanned.PadRight(20, ' ');
string sActual = ActualQty.ToString("#,##0");
string sActualNew = ActualQty.ToString("#,##0");
if (sActual.Length < 20)
sActualNew = sActual.PadRight(20, ' ');
string site = e.Value.ToString().Trim();
string siteNew;
if (site.Length < 20)
{
siteNew = site.PadRight(20, ' ');
}
else
siteNew = site;
string Header = string.Concat(siteNew, " Planned Tonnes :", sPlannedNew, "Actual Tonnes : ", sActualNew);
// e.FormatString = String.Format("{0}Planned Tonnes : {1} Actual Tonnes : {2}", siteNew, sPlannedNew, sActualNew);
e.FormatString = Header;
}
}
Hope this makes sense
Thanks
Shaun