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?
You can press Ctrl+Tab to force an actual tab character being inserted.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With