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

Enter (new line)

3 Answers 150 Views
RichTextBox (obsolete as of Q3 2014 SP1)
This is a migrated thread and some comments may be shown as answers.
Frank Beerens
Top achievements
Rank 1
Frank Beerens asked on 12 Dec 2013, 02:54 PM
Hi,

When I hit enter in the richtextbox, an empty line appears between the previous and the new line (like a new paragraph).
I would like to insert a 'normal' enter/new line when I hit enter.

Is this possible? Now the only way I can achieve this is when I hit shift + enter.

Best regards.

3 Answers, 1 is accepted

Sort by
0
Frank Beerens
Top achievements
Rank 1
answered on 17 Dec 2013, 07:38 AM
Anyone???
0
Accepted
Stefan
Telerik team
answered on 17 Dec 2013, 09:19 AM
Hi Frank,

Thank you for writing.

In order to change the input behavior of the control, you should create a descendant of the InputBehavior class and override the desired method. Here is how to change the Enter key behavior as per your request:
class MyInputBehavior : InputBehavior
{
 
    public MyInputBehavior(DocumentView view)
        : base(view)
    {
 
    }
 
    protected override bool ProcessEnterKey(KeyEventArgs e)
    {
        e.SuppressKeyPress = true;
        this.DocumentView.Insert(FormattingSymbolLayoutBox.LINE_BREAK);
        return true;
    }
}

And here is how to put this behavior in action:
radRichTextBox1.DocumentView.InputBehavior = new MyInputBehavior(radRichTextBox1.DocumentView);

I hope this helps.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Frank Beerens
Top achievements
Rank 1
answered on 18 Dec 2013, 09:33 AM
Thank you, that did the job!
Tags
RichTextBox (obsolete as of Q3 2014 SP1)
Asked by
Frank Beerens
Top achievements
Rank 1
Answers by
Frank Beerens
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or