2014-09-27 96 views
0

我需要在單詞中製作項目符號列表。它從多行文本框中獲取輸入。在多行文本框中啓動的每一行都應該生成一個新的項目符號點。如何從文本框中插入項目符號列表?

這裏是什麼,我想實現一個例子:InputResult

這裏是我的代碼,其產生已經輸入的文本。 (順便說一句這是不是我的)

Paragraph assets = doc.Content.Paragraphs.Add(); 

assets.Range.ListFormat.ApplyBulletDefault(); 
string[] bulletItems = new string[] { "One", "Two", "Three" }; 

for (int i = 0; i < bulletItems.Length; i++) 
{ 
    string bulletItem = bulletItems[i]; 
    if (i < bulletItems.Length - 1) 
     bulletItem = bulletItem + "\n"; 
    assets.Range.InsertBefore(bulletItem); 
} 
+0

我不知道如何使每一行不同的變量,所以我可以插入字符串[] {「一」,「兩」,「三」};他們。 – sharpiee 2014-09-27 02:15:34

回答

1

我不是你想要什麼來實現的,但據我所知你想在TextBox每一行之前插入子彈,然後試圖把將文字轉化爲Word?

也許這段代碼會幫助你。

string[] unbulleted = textBox1.Lines; 
string[] bulleted = new string[unbulleted.Length]; 
for (int i = 0; i < bulleted.Length; i++) 
    bulleted[i] = "\u2022" + unbulleted[i]; 

所以,現在你有一個字符串[]每個字符串之前子彈!我不確定如何將其插入到Word中。

+0

謝謝!只是一個問題,「\ u2022」是什麼意思? – sharpiee 2014-09-27 02:52:42

+0

這是一個項目符號的Unicode值。你可以在這裏找到它們的完整列表(http://www.fileformat.info/info/unicode/char/a.htm)! – Minato 2014-09-27 05:15:09

+0

爲了進一步解釋,「u2022」是實際值,黑色反斜槓「\」告訴計算機不要逐字地取出字符串並替換相應的Unicode字符。 – Minato 2014-09-27 05:32:10

相關問題