Click here to Skip to main content
15,909,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
why when I press a Ctrl+Tab in a multiline TextBox,it enters a tab character, even i set the AcceptsTab property to false?
i set the MultiLine property to true, and AcceptsTab property to false.
Posted
Updated 17-Oct-11 0:38am
v2
Comments
BillWoodruff 17-Oct-11 7:04am    
I cannot reproduce this behavior in .NET 4.0. If you set a TextBox MultiLine property to 'true, holding the Control key and pressing Tab will do nothing.

To avoid tab characters in multiline TextBox.AcceptsTab property should be set to true.
 
Share this answer
 
Because the AcceptsTab property only affects the TAB key - CTRL+TAB is a different keystroke, which is always inserted into a TextBox. If you want to prevent it, then look at handling the Keydown event:
C#
private void myTextBox_KeyDown(object sender, KeyEventArgs e)
    {
    if (e.KeyCode == Keys.Tab && e.Control)
        {
        e.Handled = true;
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900