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

How to auto scroll to end

3 Answers 389 Views
RichTextEditor
This is a migrated thread and some comments may be shown as answers.
Myoungsu
Top achievements
Rank 1
Myoungsu asked on 14 Sep 2015, 01:57 AM

I am developing log viewer using richtexteditor.

I do input the function whenever adding text on richtexteditor, it shows lastest part on there and cursor is located bottom on the control.

How to do it on richtexteditor.

 

And if you have more convienient choice to develop log viewer. let me know.

 

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 15 Sep 2015, 08:54 AM
Hello ,

Thank you for writing.

You can use the following code to scroll to the bottom:
private void radButton1_Click(object sender, EventArgs e)
{
    radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.Value = radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.Maximum;
}

Please let me know if there is something else I can help you with. 
 
Regards,
Dimitar
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Myoungsu
Top achievements
Rank 1
answered on 17 Sep 2015, 05:44 AM
It works well. Thanks a lot.
0
Jay
Top achievements
Rank 1
Iron
Iron
answered on 15 Feb 2023, 04:18 AM

This doesn't smoothly scroll the control to the bottom. It looks very unprofessional.

 

Dinko | Tech Support Engineer
Telerik team
commented on 15 Feb 2023, 09:44 AM

What else I can suggest is to manually change the value of the ScrollBar on every tick of DispatcherTimer. This way you could achieve a similar smooth scroll effect. For example, you could start the timer with a button click. Then you can use the radRichTextEditor1.RichTextBoxElement.ActiveEditorPresenter.ScrollToVerticalOffset() method to offset the thumb.

public int offset = 0;
private void Dt_Tick(object sender, EventArgs e)
{
    offset += 50;
    radRichTextEditor1.RichTextBoxElement.ActiveEditorPresenter.ScrollToVerticalOffset(offset);
    radRichTextEditor1.RichTextBoxElement.UpdateEditorLayout();
    if(radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.Value >= radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.Maximum - radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.LargeChange)
    {
        dt.Stop();
    }
}
DispatcherTimer dt = new DispatcherTimer();
private void radButton1_Click(object sender, EventArgs e)
{
    offset = radRichTextEditor1.RichTextBoxElement.VerticalScrollBar.Value;
            
    dt.Interval = new TimeSpan(0, 0, 0, 0, 100);
    dt.Tick += Dt_Tick;
    dt.Start();
}

I hope this approach will work for you.

Tags
RichTextEditor
Asked by
Myoungsu
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Myoungsu
Top achievements
Rank 1
Jay
Top achievements
Rank 1
Iron
Iron
Share this question
or