仅在富文本框 (c#) 中段落的第二行缩进 [英] Indent only in second line in paragraph in rich text box (c#)

查看:31
本文介绍了仅在富文本框 (c#) 中段落的第二行缩进的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何只在第二行缩进,成为段落第一个单词下的空格.
像这样:

How can I make indent only in the second row, to be space under the first word of paragraph.
as this:

推荐答案

如果可以将每一行读入一个数组,循环遍历该数组,如果 index = 1 则在行首添加\t"然后将其添加到输出字符串.看看能不能写个例子.

If you can read each line into an array, loop through that array, and if index = 1 then add "\t" to the beginning of the line then adding it to the output String. Let's see if I can write up an example.

假设您已经将每一行读入 String[] 行.

Let's say you already read each line into String[] lines.

String[] lines = readFromTextFileLineByLine();
String output = "";
int index = 0;
foreach(String line in lines)
{
    if(index==1)
        line = "\t" + line;
    output += line;
    index++;
}

我希望这会有所帮助.

现在对于富文本框中的每个段落都会有所不同.也许你可以用\n"分割文本,而不是逐行读取文件,然后运行它来改变你的输出.但是,您会遇到新行出现的位置以及文本框的宽度大小的问题.

Now for each paragraph in a richtextbox would be a bit different. Maybe you can split the text up by "\n", instead of reading from a file line by line, then running this to change your output. You will, however, run into the issue of where a new line occurs and how large the text box is width wise.

这篇关于仅在富文本框 (c#) 中段落的第二行缩进的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆