I am programatically adding blocks of text to a RichTextBox control and it
constantly "beeps" when doing so. The program is reading an xml file line by
line and when it finds certain attributes it changes their values to a
different color. This means that a line of xml might have its color changed
several times. I thought it had to do with the changing colors but when i
commented that code out it still beeped. If i write the entire line without
substringing it together i get no beeps. It only seems to happen when i
break the line up and substring it back together.

example:
the True part will beep but the false part will not. Color changing has been
omitted since it's not a factor.

if (true)
{
rtb1.SelectedText = line.Substring(0,10); // originally set color to
black
rtb1.SelectedText = line.Substring(11,10); // changed color to red
rtb1.SelectedText = line.Substring(21,10) + "\r\n"; // changed back to
black
}
else
{
rtb1.SelectedText = line + "\r\n";
}

Anyone know why this happens and is there a way to stop it?

Thanks,

David

Re: RichTextBox - beeping by David

David
Thu May 19 10:40:23 CDT 2005

Figured it out. It's because I made the control a ReadOnly (to prevent users
from changing the text). I'll just make the control ReadOnly = False; prior
to updating the text and then ReadOnly = True; when I'm done.


"David Burkinshaw" <dburkinshaw@hotmail.com> wrote in message
news:OawY$JIXFHA.2768@tk2msftngp13.phx.gbl...
>I am programatically adding blocks of text to a RichTextBox control and it
>constantly "beeps" when doing so. The program is reading an xml file line
>by line and when it finds certain attributes it changes their values to a
>different color. This means that a line of xml might have its color changed
>several times. I thought it had to do with the changing colors but when i
>commented that code out it still beeped. If i write the entire line without
>substringing it together i get no beeps. It only seems to happen when i
>break the line up and substring it back together.
>
> example:
> the True part will beep but the false part will not. Color changing has
> been omitted since it's not a factor.
>
> if (true)
> {
> rtb1.SelectedText = line.Substring(0,10); // originally set color to
> black
> rtb1.SelectedText = line.Substring(11,10); // changed color to red
> rtb1.SelectedText = line.Substring(21,10) + "\r\n"; // changed back to
> black
> }
> else
> {
> rtb1.SelectedText = line + "\r\n";
> }
>
> Anyone know why this happens and is there a way to stop it?
>
> Thanks,
>
> David
>