Reputation: 105
If there is a way I can get a sum from two labels and show the result in a third label. Right now I've been having problems with the sums in one of my reports and if there's a way I can sum the labels instead of making a calculated field, I think I can solve my problem.
I was investigating in the matter and I found similar questions in the forums, but the response they give didn't solve my question. Here are the links to the questions: https://www.devexpress.com/Support/Center/Question/Details/Q316239 https://www.devexpress.com/Support/Center/Question/Details/Q470883
I'm working the reports in visual studio 2012 using c# and my DevExpress version is the 14.1.
Upvotes: 2
Views: 3524
Reputation: 6621
You can use XRControl.BeforePrint
event. In this event you can simply change the text of your label. You can get the text from your other labels:
private void xrLabel3_BeforePrint(object sender, PrintEventArgs e)
{
xrLabel3.Text = (int.Parse(xrLabel1.Text) + int.Parse(xrLabel2.Text)).ToString();
}
Also you can use XtraReportBase.GetCurrentColumnValue
method to get current values:
private void xrLabel3_BeforePrint(object sender, PrintEventArgs e)
{
xrLabel3.Text = (GetCurrentColumnValue<int>("FirstValue") + GetCurrentColumnValue<int>("SecondValue")).ToString();
}
And you can use XtraReportBase.GetCurrentRow
method to get the underlying data object:
private void xrLabel3_BeforePrint(object sender, PrintEventArgs e)
{
var yourData = (YourDataClass)GetCurrentRow();
xrLabel3.Text = (yourData.FirstValue + yourData.SecondValue).ToString();
}
Upvotes: 2