A
a_n_d_y_bell
Hi-
In my application I have a RichTextBox, and I want to scroll it so that
the character at a given index appears on the top line of the box. Up
till now, I've used this routine, which works fine:
==
rtb.Focus();
rtb.SelectionStart=rtb.Text.Length-1;
rtb.SelectionLength=0;
rtb.SelectionStart=rtb.Text.IndexOf("MY_TEXT");
rtb.SelectionLength=0;
==
However, recently I've been adding a search feature, and as a result
I've needed to set the RTB's HideSelection property to false. An
unfortunate side-effect of this is that for some reason the above code
no longer works. I've experimented with ScrollToCaret combinations, but
the problem is that if MY_TEXT is visible on-screen but half-way down
the textbox, then calling ScrollToCaret will never move the box.
Does anyone have a solution?
Cheers,
Andy
In my application I have a RichTextBox, and I want to scroll it so that
the character at a given index appears on the top line of the box. Up
till now, I've used this routine, which works fine:
==
rtb.Focus();
rtb.SelectionStart=rtb.Text.Length-1;
rtb.SelectionLength=0;
rtb.SelectionStart=rtb.Text.IndexOf("MY_TEXT");
rtb.SelectionLength=0;
==
However, recently I've been adding a search feature, and as a result
I've needed to set the RTB's HideSelection property to false. An
unfortunate side-effect of this is that for some reason the above code
no longer works. I've experimented with ScrollToCaret combinations, but
the problem is that if MY_TEXT is visible on-screen but half-way down
the textbox, then calling ScrollToCaret will never move the box.
Does anyone have a solution?
Cheers,
Andy