[英]Center Justify paragraph in RichTextBox
I use a RichTextBox, and I want to format all the lines in a paragraph with justify alignment, except the last line will be aligned to the center. 我使用RichTextBox,我想格式化对齐的段落中的所有行,除了最后一行将与中心对齐。
as this: 如下:
sssssssssssssssssssssssss
sssssssssssssssssssssssss
sssssssssssssssssssssssss
ssssssssssssss
What you want is "center justify". 你想要的是“中心辩护”。 Modify the enum, it's #5 below:
修改枚举,下面是#5:
/// <summary>
/// Specifies how text in a <see cref="AdvRichTextBox"/> is
/// horizontally aligned.
/// </summary>
public enum TextAlign
{
/// <summary>
/// The text is aligned to the left.
/// </summary>
Left = 1,
/// <summary>
/// The text is aligned to the right.
/// </summary>
Right = 2,
/// <summary>
/// The text is aligned in the center.
/// </summary>
Center = 3,
/// <summary>
/// The text is justified.
/// </summary>
Justify = 4,
/// <summary>
/// The text is center justified.
/// </summary>
CenterJustify = 5
}
Sample code: 示例代码:
private void Form1_Load(object sender, EventArgs e)
{
AdvRichTextBox tb = new AdvRichTextBox();
tb.SelectionAlignment = TextAlign.CenterJustify;
tb.SelectedText = "Here is a justified paragraph. It will show up justified using the new AdvRichTextBox control created by who knows.\n";
tb.Width = 250;
tb.Height = 450;
this.Controls.Add(tb);
}
<RichTextBox>
<FlowDocument>
<Paragraph TextAlignment="Justify">
sssssssssssssssssssssssss
sssssssssssssssssssssssss
sssssssssssssssssssssssss
</Paragraph>
<Paragraph TextAlignment="Center">
sssssssssssssssssssssssss
</Paragraph>
</FlowDocument>
</RichTextBox>
Mainly using Paragraph TextAlignment will give you the option to align the text: 1. Justify, 2. Center, 3. Left, 4. Right; 主要使用Paragraph TextAlignment将为您提供对齐文本的选项:1。Justify,2。Center,3。Left,4。Right;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.