Using a script to centre text

I have a report that has a label in it - The script to populate the label is:

private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
xrDispatchZone.Text = string.Format("{0}: {1}. {2}: {3}", (“Dispatch Zone”), DetailReport.GetCurrentColumnValue(“LT_O_DispatchZone”), (“Client Group (Billing)”), DetailReport.GetCurrentColumnValue(“LT_O_ClientGroup”));

The one issue that I have is that it is always left aligned even though the label is set to be centre aligned. Is there any way within that script to add a command to centre the text?

I’m not sure why your label is encountering that.

As I don’t have a copy of your report template here, I tested this with the label in the Sample Detailed Service Workorder with Grand Total - the label that uses the script to combine city, state and postal code.

I edited the property TextAlignment to MiddleRight, and previewed, and it definitely does it.

I do not have information on how to use text alignment in a script - I would suggestperforming a search online for C# text alignment, as it may show examples.

But I would suggest instead checking your label properties, as when I do it in a sample report template that is using a script to combine fields, the property TextAlignment works correctly.

  • Joyce

Thank You - I took what you said and deleted the label, recreated from scratch and it worked fine? Might be a remnant or corruption from the previous version of Ayanova?