RichTextBox not scrolling as I type

6 posts, 0 answers
  1. Michael Evans
    Michael Evans avatar
    31 posts
    Member since:
    Mar 2010

    Posted 25 Aug 2010 Link to this post

    I have a RichTextBox control that I am using to display formatted text (bold, underline, forecolor, etc.)  I do not want to allow the user to enter multiple lines, so I've placed the document's LayoutMode to FlowNoWrap.  This works out pretty well for what I want, except for the fact that when I type text that is longer than the width of the control, the text does not scroll so that I can see what text has been typed, like it does in a normal text box.

    If the Horizontal scroll bars are on, I can scroll over to see the text, but the user should be able to see what they are typing as they type it.  Also, the width of the text area is pretty large which means as soon as they scroll even a little bit, everything they typed is no longer being displayed, unless they creep along pushing the arrows at the end of the scrollbar.

    Is there any way to get the cursor/caret to always be on the screen?

    Here's the XAML for the RichTextBox:

     

     

     

    <telerik:RadRichTextBox x:Name="RichText1"

     

     

     

    BorderBrush="{Binding Path=BorderBrush, ElementName=tbShortName}"

     

     

     

    BorderThickness="1"

     

     

     

    Loaded="RichText1_Loaded"

     

     

     

    HorizontalAlignment="Stretch"

     

     

     

    VerticalAlignment="Stretch"

     

     

     

    KeyDown="RichText1_KeyDown"

     

     

     

    Margin="5"

     

     

     

    HorizontalScrollBarVisibility="Hidden"

     

     

     

    CurrentSpanStyleChanged="RichText1_CurrentSpanStyleChanged">


    and the code-behind where I create the document, section, and paragraph:

     

     

     

    private void RichText1_Loaded(object sender, RoutedEventArgs e)

     

    {

     

     

    RadDocument document = new RadDocument();

     

    document.LayoutMode =

     

    DocumentLayoutMode.FlowNoWrap;

     

    document.SectionDefaultPageMargin =

     

    new Padding(5);

     

     

     

    Section section = new Section();

     

    document.Sections.Add(section);

    _messageParagraph =

     

    new Paragraph();

     

    _messageParagraph.SpacingAfter = 0;

    section.Paragraphs.Add(_messageParagraph);

    RichText1.Document = document;

    }

     

     


  2. Alex
    Admin
    Alex avatar
    129 posts

    Posted 30 Aug 2010 Link to this post

    Hi Michael Evans,

    Unfortunately, at this moment the FlowNoWrap layout mode is still not fully support and we recommend you not to use it for now. This mode will be officially supported for the Q3 release. I've created a PITS item on the matter so you can track it's progress here.

    We appreciate you taking the time to submit the issues you've found so I've added some points to your Telerik account.

    Kind regards,

    Alex
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Tayyab
    Tayyab avatar
    7 posts
    Member since:
    Jul 2012

    Posted 26 Jul 2012 Link to this post

    Hi I used this code to change layout of Document and this code snippets run when a button click to change layout, but when the FlowNoWrap layout is select after Flow layout the VS stops responding I don't know why. the whole program crashed 

     public long SetViewMode(long viewMode)
    {
     if (viewMode == 0)
                    this.radRichTextBox1.ChangeLayoutMode(DocumentLayoutMode.Flow);
                else if (viewMode == 1)
                    this.radRichTextBox1.ChangeLayoutMode(DocumentLayoutMode.FlowNoWrap);
                else
                    this.radRichTextBox1.ChangeLayoutMode(DocumentLayoutMode.Paged);

    }

    one more thing in my mind that can we change layout mode from flow to FlowNoWrap ? 

    After that I changed the code to this and it works fine. here lastView is a global variable

            public long SetViewMode(long viewMode)
            {
                if (viewMode == 0)
                    this.radRichTextBox1.ChangeLayoutMode(DocumentLayoutMode.Flow);
                else if (viewMode == 1)
                {
                    if(lastView != 0)
                    this.radRichTextBox1.ChangeLayoutMode(DocumentLayoutMode.FlowNoWrap);
                }
                else
                    this.radRichTextBox1.ChangeLayoutMode(DocumentLayoutMode.Paged);
                lastView = viewMode;
    }



    I will wait for your reply 
  5. Petya
    Admin
    Petya avatar
    975 posts

    Posted 30 Jul 2012 Link to this post

    Hi Tayyab,

    Unfortunately, we were unable to reproduce this issue on our end.

    I suggest you check the way your document is constructed, since this may be causing the problem. You can also send us a sample document and some more details on your application logic, so we can investigate further. 

    Regards,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. DQ
    DQ avatar
    11 posts
    Member since:
    Jul 2012

    Posted 30 Jul 2012 Link to this post

    This happened to me too.  If the direct parent of the richtextbox (user control, child windows, etc.) does not have the width/height defined, RadRichTextBox controls will behave abnormally.

    Make sure that you define the width/height of the direct parent of the RadRichTextBox.
  7. Tayyab
    Tayyab avatar
    7 posts
    Member since:
    Jul 2012

    Posted 30 Jul 2012 Link to this post

    Hi DQ,

    I put the editor in Child Control and I already defined its width and height in xaml file. 

    can u please send me the code
Back to Top
DevCraft banner