0

In a winforms application, I'm using a RichTextBox and I'm trying to reduce the output from a '\t' to 4 spaces from whatever the default is. I have this in the form's OnLoad

 _richTextBox.Text = "1\t2\t3\t4\t5";
 _richTextBox.SelectAll();
 _richTextBox.SelectionTabs = new int[]  {100,200,300,400 };

I have a breakpoint before and after this snippet. The SelectionTabs is set to {int[0]} (empty int array) before and after the assignment. Can anyone tell me why my assignment is not going through?

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • quite difficult to understand your problem, can you add more details – volody May 20 '10 at 13:54
  • No repro, this code works fine when I try it. Both on screen and in the debugger. There's no obvious failure mode, nor have I ever seen one reported. – Hans Passant May 20 '10 at 15:43
  • There were some event handlers on the RichTextBox (GotFocus, TextChanged, SwelectionChanged, etc). I disabled all of them and it started working. Now I'm trying to figure out what exactly those eventhandlers were doing that was preventing the setting of SelectionTabs. Thanks guys. – Bala R May 20 '10 at 18:57

1 Answers1

2

Try setting the SelectionTabs property before putting anything into the text box (and/or selecting anything).

See Modifying default tab size in RichTextBox.

Community
  • 1
  • 1
NascarEd
  • 1,380
  • 12
  • 14