2017-03-05 70 views
0

在Microsoft Word中製作項目符號列表時,按tabbackspace改變當前子彈點的位置,就像這樣:RichTextBox的子彈縮進(.NET表格)

  • 子彈一
    • 縮進子彈
  • 子彈兩

然而,在RTB,壓片產生以下結果:

  • 子彈一
  •            縮進子彈
  • 子彈兩

有沒有乾淨的方式做到這一點?或者我需要看看創建一個自定義RTB? (如果有,請提供代碼段)

謝謝!

+0

添加的WinForm/WPF /?標籤的問題,你可以處理tab鍵事件http://stackoverflow.com/questions/16181026/converting-tabs-into-spaces-in-a-richtextbox – Slai

+0

使用的DevExpress可以幫助您解決問題的https:/ /documentation.devexpress.com/#WindowsForms/CustomDocument5812 –

回答

0

您可以通過使用事件,例如做;

代碼;

private void Form1_Load(object sender, EventArgs e) 
{ 
    richTextBox1.SelectionBullet = true; 
    richTextBox1.AcceptsTab = true; 
} 

private void richTextBox1_KeyUp(object sender, KeyEventArgs e) 
{ 
    if (e.KeyCode == Keys.Tab) 
    { 
      richTextBox1.SelectionIndent = 30; 
    } 
    if (e.KeyCode == Keys.Enter) 
    { 
      richTextBox1.SelectionIndent = 0; 
    } 
} 

結果; enter image description here

希望幫助,