L
Leon Friesema
Hi,
I'm working on a RichTextBox with some "in-program" style-features
(e.g. *no way* becomes bold : like MS Word does). Got everything
working fine, flickerfree and reasonable fast, but in order to set the
style of some part of the text I use the "Selection" method (in the
case of *text* the
richTextBox1.SelectionFont.Bold = true
No problem so far, unless there are scrollbars involved. Somehow, when
I type into the RichTextBox (and after the styles are applied) the
current selection position becomes the top row; unless there is no
"scrollbar left" to scroll down to.
I've added a small sample of the code below
What am I missing, is there a property or method I could use?
TIA,
Leon
I'm working on a RichTextBox with some "in-program" style-features
(e.g. *no way* becomes bold : like MS Word does). Got everything
working fine, flickerfree and reasonable fast, but in order to set the
style of some part of the text I use the "Selection" method (in the
case of *text* the
richTextBox1.SelectionFont.Bold = true
No problem so far, unless there are scrollbars involved. Somehow, when
I type into the RichTextBox (and after the styles are applied) the
current selection position becomes the top row; unless there is no
"scrollbar left" to scroll down to.
I've added a small sample of the code below
Code:
Cursor = Cursors.WaitCursor;
int origSelStart = richTextBox1.SelectionStart;
int origSelLength = richTextBox1.SelectionLength;
// Freeze control
SendMessage(richTextBox1.Handle, 11, 0, 0);
if (SingleLine)
{
// Only do the appropriate line
ApplyLineStyle(Line);
}
else
{
// Apply style on all lines
for (int i = 0; i < richTextBox1.Lines.GetLength(0); i++)
{
ApplyLineStyle(i, false);
}
}
// Unfreeze control
SendMessage(richTextBox1.Handle, 11, 1, 0);
richTextBox1.Refresh();
// Turn original selection-state back
richTextBox1.SelectionStart = origSelStart;
richTextBox1.SelectionLength = origSelLength;
SingleLine = false;
Cursor = Cursors.Default;
What am I missing, is there a property or method I could use?
TIA,
Leon