Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RichTextBox and tab key

Tags:

c#

forms

I created a richTextBox and i noticed that when I press Tab key it is not doing anything. It is suppose to do some space but it do not.

How can i access it?

like image 331
user2203448 Avatar asked Mar 26 '13 19:03

user2203448


People also ask

When should we use RichTextBox?

A RichTextBox is a better choice when it is necessary for the user to edit formatted text, images, tables, or other rich content. For example, editing a document, article, or blog that requires formatting, images, etc is best accomplished using a RichTextBox.

What is RichTextBox?

In C#, RichTextBox control is a textbox which gives you rich text editing controls and advanced formatting features also includes a loading rich text format (RTF) files. Or in other words, RichTextBox controls allows you to display or edit flow content, including paragraphs, images, tables, etc.


2 Answers

By default pressing tab moves focus to the next control. Setting AcceptsTab property of the RichTextBox to true allows the RichTextBox to accept tab characters.

See this MSDN article on the AcceptsTab property.

like image 144
Paul Sasik Avatar answered Oct 05 '22 23:10

Paul Sasik


First you need to set following properties of Richtextbox

richTextBox.Multiline = true;
richTextBox.AcceptsTab = true;

And in the keypress event of richtextbox you need to do following

if (e.KeyChar == 9)
{
    e.Handled = false;
}
like image 28
Uday Phadke Avatar answered Oct 05 '22 23:10

Uday Phadke