开发者

why when I press a Ctrl+Tab in a MultiLine TextBox,it enters a tab character, even i set the AcceptsTab property to false

开发者 https://www.devze.com 2023-04-13 07:22 出处:网络
Why does pressing Ctrl开发者_JAVA百科+Tab in a MultiLine TextBox enter a tab character even though I set the AcceptsTab property to false?

Why does pressing Ctrl开发者_JAVA百科+Tab in a MultiLine TextBox enter a tab character even though I set the AcceptsTab property to false?

I set the MultiLine property to true and the AcceptsTab property to false.


The Ctrl-tab key press is treated differently from a tab key press. If you handle the Ctrl-tab in your TextBox_KeyDown event, you can ignore it:

    private void textBox1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Control && e.KeyCode == Keys.Tab)
            e.Handled = true;
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号