Report Script: Multi-line text line spacing (19): Difference between revisions

From AutoCount Resource Center
Content added Content deleted
(Created page with "==Introduction== XRLabel control is a text display that does not provide spacing between lines.<br/>However, XRRichText control has the properties to set the text spacing betw...")
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 12: Line 12:
{{SourceDownload|link=https://drive.google.com/open?id=1aat9_8TB44qSLo13mPoMlIdoXpf84NPq|remark=(AutoCount Accounting 1.8 / 1.9)|Download Report Template|Invoice (Spacing in Description with RichText)}}
{{SourceDownload|link=https://drive.google.com/open?id=1aat9_8TB44qSLo13mPoMlIdoXpf84NPq|remark=(AutoCount Accounting 1.8 / 1.9)|Download Report Template|Invoice (Spacing in Description with RichText)}}
[[File:ReportScript.TextLineSpacing.png|link=]]<br />
[[File:ReportScript.TextLineSpacing.png|link=]]<br />
<br/>

==Report Design==
==Report Design==
#Replace the '''Label''' (XRLabel) that is bound to "Description" with '''Rich Text''' (XRRichText) control
#Replace the '''Label''' (XRLabel) that is bound to "Description" with '''Rich Text''' (XRRichText) control
#Change the font of XRRichText to "Tahoma", and font size = 9
#Change the '''(Name)''' to "xrRTItemDesc" (in Property Grid)
#Amend the (Name) to "xrRTItemDesc"
#Change font of xrRTItemDesc
#*Font Name = "Tahoma"
#*Font size = 9
#In Property Grid, Click [+] button of Scripts to reveal the events of this Rich Text
#In Property Grid, Click [+] button of Scripts to reveal the events of this Rich Text
#Find Before Print, and click into the text box on the right
#Find Before Print, and click into the text box on the right
Line 31: Line 33:
===Add function call in xrRTItemDesc_BeforePrint event===
===Add function call in xrRTItemDesc_BeforePrint event===
<syntaxhighlight lang="csharp">
<syntaxhighlight lang="csharp">
private void richText1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
private void xrRTItemDesc_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
{
string desc = DetailReport.GetCurrentColumnValue("Description").ToString();
string desc = DetailReport.GetCurrentColumnValue("Description").ToString();


//You may change the value of spacing
//Line spacing is set to 1.5 pt.
//You may change the value of spacing, but always end with letter 'f'.
(sender as XRRichText).Text = FormatLineSpacing(desc, 1.5f);
(sender as XRRichText).Text = FormatLineSpacing(desc, 1.5f);
}
}

Latest revision as of 03:41, 30 January 2019

Introduction

XRLabel control is a text display that does not provide spacing between lines.
However, XRRichText control has the properties to set the text spacing between two lines. This tutorial shows how can be done with simple scripting.

Task in this tutorial

  • Replace XRLabel with XRRichText
  • Use RichEditDocumentServer to manipulate paragraph line spacing

Product

AutoCount Accounting 1.8 / 1.9
Applicable to AutoCount Accounting 2.0

Download Report Template (AutoCount Accounting 1.8 / 1.9)

Invoice (Spacing in Description with RichText)



Report Design

  1. Replace the Label (XRLabel) that is bound to "Description" with Rich Text (XRRichText) control
  2. Change the (Name) to "xrRTItemDesc" (in Property Grid)
  3. Change font of xrRTItemDesc
    • Font Name = "Tahoma"
    • Font size = 9
  4. In Property Grid, Click [+] button of Scripts to reveal the events of this Rich Text
  5. Find Before Print, and click into the text box on the right
  6. Then click the arrow button, and click (New)
    Report Designer will switch to Scripts editor,
    and xrRTItemDesc_BeforePrint event is created.

Report Script

Add using directive

  1. Add directive at the top of Scripts, if has not already added.
    • using DevExpress.XtraRichEdit;
    • using DevExpress.XtraRichEdit.API.Native;

Add function call in xrRTItemDesc_BeforePrint event

private void xrRTItemDesc_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{
	string desc = DetailReport.GetCurrentColumnValue("Description").ToString();

	//Line spacing is set to 1.5 pt.
	//You may change the value of spacing, but always end with letter 'f'.
	(sender as XRRichText).Text = FormatLineSpacing(desc, 1.5f);
}

Add function of FormatLineSpacing

This function will format the line spacing of a text.

private string FormatLineSpacing(string text, float spacing)
{
	RichEditDocumentServer docServer = new RichEditDocumentServer();
	docServer.Text = text;
	docServer.Document.DefaultParagraphProperties.LineSpacingType = ParagraphLineSpacing.Multiple;
	docServer.Document.DefaultParagraphProperties.LineSpacingMultiplier = spacing;	
	return docServer.RtfText;
}


Go to menu

Go to top
Resources For AutoCount Software Developers