This is a migrated thread and some comments may be shown as answers.

RichTextBox not scrolling as I type

5 Answers 152 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael Evans
Top achievements
Rank 1
Michael Evans asked on 25 Aug 2010, 09:16 PM
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;

}

 

 


5 Answers, 1 is accepted

Sort by
0
Alex
Telerik team
answered on 30 Aug 2010, 12:59 PM
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
0
Tayyab
Top achievements
Rank 1
answered on 26 Jul 2012, 07:05 PM
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 
0
Petya
Telerik team
answered on 30 Jul 2012, 03:39 PM
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.

0
DQ
Top achievements
Rank 1
answered on 30 Jul 2012, 04:57 PM
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.
0
Tayyab
Top achievements
Rank 1
answered on 30 Jul 2012, 05:03 PM
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
Tags
RichTextBox
Asked by
Michael Evans
Top achievements
Rank 1
Answers by
Alex
Telerik team
Tayyab
Top achievements
Rank 1
Petya
Telerik team
DQ
Top achievements
Rank 1
Share this question
or