Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RichTextBox Bullet Indent (.NET Forms)

In Microsoft Word, when making a bulleted list, pressing tab or backspace changes the position of the current bullet point, like this:

  • Bullet One
    • Indented Bullet
  • Bullet Two

However, In the RTB, pressing tab produces the following result:

  • Bullet One
  •       Indented Bullet
  • Bullet Two

Is there any clean way to achieve this? Or do I need to look at creating a custom RTB? (If so please provide code snippet)

Thanks!

like image 987
criticaldiamonds Avatar asked Dec 19 '25 00:12

criticaldiamonds


1 Answers

You can do it by using events, for example;

Code;

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

Result; enter image description here

Hope helps,

like image 70
Berkay Yaylacı Avatar answered Dec 20 '25 14:12

Berkay Yaylacı



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!