Position RichTextBox to specified character position

Position RichTextBox to specified character position

Post by Andru » Sun, 19 Oct 2008 04:50:35


Pete,


Thank you very much. Current position is character index in source text. I
used Select() and this worked.

However the bad line where cursor is moved is not visible well.

How to make this line more visible, e.q add exclamation sign before line
like in DataGridView or
make bold or higlight or underline it in some special way
like in VS so that this is removed when cursor moves to next line ?

Errorprovider icon blinks nicely so this would be nice to use.

However I havent found a way to put errorprovider icon before Select() by
positon line in RichTextBox.

Andrus.
 
 
 

Position RichTextBox to specified character position

Post by Peter Duni » Sun, 19 Oct 2008 05:53:09


You can do whatever you want, as long as it's supported within the
RichTextBox formatting ability. Just apply whatever formatting or insert
whatever new text or graphics you want to provide the highlighting. You
can handle the SelectionChanged event to track when the text cursor (also
known as "caret") is moved, so that you know when to remove whatever
formatting change you've applied.

Pete

 
 
 

Position RichTextBox to specified character position

Post by Andru » Mon, 20 Oct 2008 05:53:15

Pete,


Thank you very much.
I havent ever programmed richtextbox.
Where to find some sample which implements this ?

Andrus.
 
 
 

Position RichTextBox to specified character position

Post by Peter Duni » Mon, 20 Oct 2008 08:05:12


Are you asking about the icon specifically, or just formatting in general?

I don't actually know whether you can in fact easily insert an image into
a RichTextBox; that is, I don't know of any specific methods on the
RichTextBox class (you can always edit the RTF directly, of course). Even
if you can, note that the example you gave for a blinking icon is not
inherent to the image; the ErrorProvider class starts a timer when you set
the error, and handles the blinking explicitly, outside the image data
itself. You would probably have to do something similar when trying to
cause an image in a RichTextBox to blink.

But as far as formatting in general goes, MSDN has a number of code
samples related to using the RichTextBox class, including examples of how
to set formatting using the various format-related properties and methods
on the class. As long as you are not dead-set on having a blinking image
in your RichTextBox, it should be reasonably straightforward for you to
implement what you want using the MSDN docs.

http://www.yqcomputer.com/

Pete