Event when Vertical text overflows m_scroll Viewport

Jul 1, 2008 at 2:54 AM
I have been trying to find a way to fire an event (custom event) when the vertical text flows past the m_scroll...., I think it is called a viewport.  I stubbed out a new event and was all ready to go when I realized I have no idea how to determine if a "line" is past the normal viewport.  I figured the best place to check would most likely be in the RichTextBox Update method or the InternalInsertString method. I tried checking visibility, m_Scroll.ComputedVerticalScrollBarVisibility, etc. and no property I could think of was giving me any love.  Visual elements are a rather new concept to me as I have been stuck in blah HTML world for so long!  Any suggestions on where and what properties I could check to determine that text has verticaly overlfowed would be a huge help.

Thank you for your time!
Jul 1, 2008 at 2:54 PM
Why would you need to do this?

Maybe you could intercept the SizeChanged event of "m_Surface" and compare the "m_Surface.ActualHeight" to the "m_Scroll.Height". In my opinion it should also be enough to just check the "m_Scroll.ComputedVerticalScrollBarVisibility" in the mentioned event...

Jul 1, 2008 at 8:01 PM
Edited Jul 1, 2008 at 8:49 PM
Thanks for your time Chris! 

The Why:
I would like to be able to prevent vertical scrolling and, as an alternative, tile multiple RichTextEdits with subsets of text if the text passed in was too large to display in it's height.  For an example perhaps have the RichTextEdit on the side of a cube and if the text overflows, create a new RichTextEdit and add it to a canvas on another side of a cube.  I didn't think I would be able to tell how much the visual space the Serialized text would fill without actually letting the control apply the formatting first but perhaps there would be a way to tell prior to adding it to a RichTextEdit.

I want to say I checked the m_Scroll.ComputedVerticalScrollBarVisibility and it was true in all cases but I was checking in the other methods.  I have not tried checking in the m_surface sizecahnged event though so that may be why.  I will try your suggestions and let you know.

Thanks again!

Just to clarify - in the cube example above the RichTextEdit would be ReadOnly and used to display what was serialized from a previous RichTextEdit that was stored in a database.

Jul 2, 2008 at 1:31 PM

I Don't think it's the best idea to use multiple rich text edits to do this... Maybe you should think about letting Update() render the content to "m_Surface" and then just divide it into as much subsurfaces as you need (add the code directly after the last instruction in Update()). I am not really sure but as LineItems contains all the references and "m_Surface" is just a parent for displaying it should cause no trouble by re-parenting all childs in "m_Surface" to multiple surfaces on your cube according to their calculated location within the "m_Surface"...

Jul 2, 2008 at 2:43 PM
Your suggestion on using the sizechanged worked great!

As for re-parenting, I think that could easily qualify as one of the best ideas I have ever heard.  That should simplify things a great deal. 
I will give that a shot.

Thank you so much for your time and great suggestions!