Does Setting RichTextBox.SeletcionStart Change RichTextBox.Text ?!?!?

  • Thread starter Thread starter eBob.com
  • Start date Start date
E

eBob.com

After a lot of debugging effort I have to conclude that it does. Or at
least can. I take a substring (RichTextBox.Text.Substring) before setting
SelectionStart and after and get a different result. The second result
begins two characters to the right of the first.

In an earlier version of the program I did not have this problem. But in
that version the RichTextBox actually appeared on a form. In the version of
the program with the problem the RichTextBox is never added to a form.

I don't know if I am asking a question or reporting a bug.

Bob
 
Well ... I just wrote a little program to demonstrate the problem and, of
course, it didn't demonstrate the problem! But here's the code which
convinces me that the RichTextBox.Text field changes when the SelectionStart
property is set ...

Target = rtb.Text.Substring(SSI + SSL + StartAdjust, FSL) 'for debugging
purposes only

rtb.Focus()

Target = rtb.Text.Substring(SSI + SSL + StartAdjust, FSL) 'for debugging
purposes only

rtb.SelectionStart = SSI

Target = rtb.Text.Substring(SSI + SSL + StartAdjust, FSL) 'for debugging
purposes only

After the last statement the value of Target is different from the values of
Target resulting from the earlier Target= statements.
 
Back
Top