Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting tabs in a textbox

This is going to turn out to be simple, I'm sure, but I couldn't find anything on Google about this. I have a Winforms application that has a textbox. When I hit the TAB key, the cursor is jumping to the next control. What I want instead is for an actual tab (or 4 spaces) to be inserted into my textbox. What property am I missing?

like image 307
Icemanind Avatar asked Sep 21 '12 22:09

Icemanind


People also ask

How do I insert a tab in a text box?

You can press Ctrl+Tab to force an actual tab character being inserted.

How do I get tabs to work in textarea?

If the keyCode is 9 (which is the key code for the tab key), we preventDefault() — this means preventing the browser's default behavior, which is usually leaving the textarea to go to the next element. Now, we use setRangeText() , which allows us to manipulate text in the textarea.


1 Answers

You should set the AcceptsTab property to true on your TextBox. This will insert an actual TAB character.

From the MSDN page:

The Multiline property must also be true to get a TAB character in the control.

If the AcceptsTab property is set to true, the user must press CTRL+TAB to move the focus to the next control in the tab order.

like image 71
Dan Avatar answered Sep 21 '22 01:09

Dan