BrickStringFormat.ChangeAlignment(StringAlignment, StringAlignment) Method
Returns a BrickStringFormat object cloned from the current BrickStringFormat object, with the new string and line alignment applied.
Namespace: DevExpress.XtraPrinting
Assembly: DevExpress.Printing.v24.2.Core.dll
Declaration
public BrickStringFormat ChangeAlignment(
StringAlignment newAlignment,
StringAlignment newLineAlignment
)
Parameters
Name | Type | Description |
---|---|---|
newAlignment | StringAlignment | A StringAlignment enumeration value, representing new string alignment. |
newLineAlignment | StringAlignment | A StringAlignment enumeration value, representing new line alignment. |
Returns
Type | Description |
---|---|
BrickStringFormat | A cloned BrickStringFormat object. |
Remarks
This method clones the current BrickStringFormat object, replaces the current value of the BrickStringFormat.Alignment property with the value specified by the newAlignment parameter and the BrickStringFormat.LineAlignment property value with the newLineAlignment parameter.
Example
This example illustrates use of the BrickStringFormat.ChangeAlignment and BrickStringFormat.ChangeLineAlignment methods to change horizontal and vertical alignment of text within the brick. It creates and displays two bricks - the first brick has default settings, the second one has its text alignment modified.
using DevExpress.XtraPrinting;
// ...
VisualBrick visBrick;
BrickGraphics brickGraph = printingSystem1.Graph;
string s = "Developer Express Inc.";
BrickStringFormat brickSFormat = new BrickStringFormat();
// Start the report generation.
printingSystem1.Begin();
// Specify a page area.
brickGraph.Modifier = BrickModifier.Detail;
// Create a rectangle.
RectangleF rect = new RectangleF(new PointF(0, 0), new SizeF(180, 50));
// Add a brick to the report.
visBrick = brickGraph.DrawString(s, Color.MidnightBlue, rect, BorderSide.All);
// Change the text alignment within the brick
brickSFormat = visBrick.Style.StringFormat.ChangeAlignment(StringAlignment.Far);
brickSFormat = brickSFormat.ChangeLineAlignment(StringAlignment.Far);
brickGraph.StringFormat = brickSFormat;
// Create a second rectangle.
RectangleF rect1 = new RectangleF(new PointF(0,50), new SizeF(180, 50));
// Add the next brick to the report.
visBrick = brickGraph.DrawString(s, Color.MidnightBlue, rect1, BorderSide.All);
// Finish the report generation.
printingSystem1.End();
// Preview the report.
printingSystem1.PreviewFormEx.Show();