2012-08-07 101 views
3

我使用RichTextBox,我想用對齊方式對齊段落中的所有行,但最後一行將對齊中心。RichTextBox中的中心對齊段落

就象這樣:

 sssssssssssssssssssssssss 
     sssssssssssssssssssssssss 
     sssssssssssssssssssssssss 
      ssssssssssssss  

我用this code爲兩端對齊。

+0

你有沒有找到一個解決這個?戶。 – 2012-12-13 10:07:28

回答

0

你想要的是「中心證明」。修改枚舉,這是低於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 
} 

enter image description here

示例代碼:

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); 
} 
+1

+1這可能是正確的答案:)(我承認我在理解OP的目標方面有很多困難......) – digEmAll 2012-08-07 12:16:13

+0

@digEmAll - 同意! – 2012-08-07 12:19:26

+0

首先,謝謝。其次,在我的電腦上,它將整個段落格式化爲中心。這是爲什麼? (注意:困難是因爲我,我不太瞭解英語) – user1543998 2012-08-07 12:38:35