G
Guest
Hello,
I've asked about this kind of thing before but I'm still having problems
with it. Below is a stripped down version of my code to do a backspace in a
multiline RichTextBox. I know it still needs some work to make it work for
all cases but my question is more basic so I think you can probably ignore
the minor details (?). My main question concerns why all the text in the box
flashes each time I do a backspace and what can be done to prevent it.
Although I may be mistaken, it appears that during the bacspace algorithm the
caret momentarily jumps to the beginning of the string containing the text
for the entire control, then back to where it belongs. Commercial
applications I've seen don't have this problem so I'm sure I'm doing
something wrong. Any ideas?
Thanks,
Ray
if (ch == '\b')
{
int lineNo = rtfTerminal.Lines.Length - 1;
if (lineNo >= 0)
{
int colNo = rtfTerminal.Lines[lineNo].Length - 1;
if (colNo > 0 && rtfTerminal.Lines[lineNo][colNo] != '\n')
{
string s = rtfTerminal.Lines[lineNo].Substring(0, colNo);
string[] lines = rtfTerminal.Lines;
lines[lineNo] = s;
rtfTerminal.Lines = lines;
rtfTerminal.Select(rtfTerminal.TextLength, 0);
}
}
}
I've asked about this kind of thing before but I'm still having problems
with it. Below is a stripped down version of my code to do a backspace in a
multiline RichTextBox. I know it still needs some work to make it work for
all cases but my question is more basic so I think you can probably ignore
the minor details (?). My main question concerns why all the text in the box
flashes each time I do a backspace and what can be done to prevent it.
Although I may be mistaken, it appears that during the bacspace algorithm the
caret momentarily jumps to the beginning of the string containing the text
for the entire control, then back to where it belongs. Commercial
applications I've seen don't have this problem so I'm sure I'm doing
something wrong. Any ideas?
Thanks,
Ray
if (ch == '\b')
{
int lineNo = rtfTerminal.Lines.Length - 1;
if (lineNo >= 0)
{
int colNo = rtfTerminal.Lines[lineNo].Length - 1;
if (colNo > 0 && rtfTerminal.Lines[lineNo][colNo] != '\n')
{
string s = rtfTerminal.Lines[lineNo].Substring(0, colNo);
string[] lines = rtfTerminal.Lines;
lines[lineNo] = s;
rtfTerminal.Lines = lines;
rtfTerminal.Select(rtfTerminal.TextLength, 0);
}
}
}