Indent only in second line in paragraph in rich text box (c#)

ぃ、小莉子 提交于 2019-12-11 01:17:11

问题


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


回答1:


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.

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

I hope this helps.

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.



来源:https://stackoverflow.com/questions/11953670/indent-only-in-second-line-in-paragraph-in-rich-text-box-c

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!