[英]how to format in RTF using c#?
我在richTextBox控件中有以下文本。
我想格式化下面的文本
RTF框可以為您提供幫助,使用RTF的唯一幫助將是使用Kosala提到的表格。
您可以為此使用字符串操作:
int equalPos = 20;
for (int l = 0; l < rtfBox.Lines.Length; l++) {
int i = rtfBox.lines[i].IndexOf('=');
int n = equalPos - i;
if ((i >= 0) && (n > 0)) {
rtfBox.lines[i] = rtfBox.lines[i].Insert(i, new string(' ', n));
}
}
頭上寫着這個,所以請檢查是否有錯誤。
編輯:
好的,這是另一個:
for (int l = 0; l < rtfBox.Lines.Length; l++) {
int i = rtfBox.lines[i].IndexOf('=');
if (i >= 0) {
rtfBox.lines[i] = rtfBox.lines[i].Insert(i, "\t");
}
}
rtfBox.SelectAll();
rtfBox.SelectionTabs = new int[] { 100 }; // Find a value big enough!
這就是我要做的。(這些是手動步驟.. :)
1)。打開MSWord。
2)。創建一個表; 2列5行(這是您的文字)
3)。 將要設置格式的文本放在表格的正確單元格中
4)。 將Word文檔另存為rtf文件。
5)。 在記事本中打開rtf文件(記事本++更好)
在那里。現在您可以找到其格式。 現在,用C#來完成它應該不難。 祝好運。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.