【问题标题】:How can i make that the lines in richTextBox1 will start from the right to the left?如何使richTextBox1 中的行从右到左开始?
【发布时间】:2014-09-11 17:45:53
【问题描述】:

有些行已经从右边开始,因为它们很长。但总的来说,所有的线都粘在左边。 我想把它们对齐到右边。

这就是我将文本分配给richTextBox的方式:

combindedString = string.Join(Environment.NewLine, ListsExtractions.myList);
richTextBox1.Text = combindedString;

我的列表是List<string> myList 的格式如下:

Index 0: text
Index 1: date&time
Index 2: link
Index 3: empty/space

然后再次索引 4:文本索引 5:dateTime 等等。 我只想让它从右边开始/对齐。

【问题讨论】:

  • All RTB 中的格式设置是通过首先进行选择然后应用格式来完成的:richTextBox1.SelectAll(); richTextBox1.SelectionAlignment = Horizo​​ntalAlignment.Right;

标签: c# .net winforms


【解决方案1】:

请参阅SelectionAlignment 属性的文档:

http://msdn.microsoft.com/en-us/library/system.windows.forms.richtextbox.selectionalignment%28v=VS.100%29.aspx

像这样使用上面的(在你的场景中):

richTextBox1.SelectAll();
richTextBox1.SelectionAlignment = HorizontalAlignment.Right;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-05
    • 2021-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多