The absolute value of DevExpress XtraReports

I have a negative value from the sum, and I need an absolute value. FYI value is in the label.

+3
source share
2 answers

The label that is used for the amount has a SummaryCalculated event .

private void xrLabel1_SummaryCalculated(object sender, TextFormatEventArgs e) {
  xrLabel1.Text = Math.Abs(Convert.ToInt32(e.Value)).ToString();
}
+2
source

You just need to use the Math.AbsMethod

Returns the absolute value of the specified number.

For instance:

string s = YourLabelControl.Text;
int i;
if(Int32.TryParse(s, out i))
{
  int abs = Math.Abs(i);
}
else
{
  //Your Label value is not a valid int.
}
0
source

All Articles