1
votes

I have a TextBox and set the MiltiLine property to true and AcceptsTab property to false.

When the TextBox has focus and i press Tab it works fine and the next control get the focus, but when i press Ctrl+Tab it works as if AcceptsTab property is set to true and makes a tab character into the TextBox.

The reason i press Ctrl+Tab.. when switching between forms in my MDI application.

Now how to make a Ctrl+Tab when pressed works like Tab when pressed in a MultiLine TextBox?

1
Hello. Sorry, may be I didn't understand question. Well, I created WinForms project, put TabControl, multiline TextBox and Button at first tab. Textbox AcceptsTab property is set to false. On Tab it moves focus to other control, on Ctrl+Tab it switches tabs. Is that needed behavior?mao
no am not using TabControl, my problem is: Am using MDI application, in the active child form and the focus is on the textbox.. when i press (Tab) only, it goes to the next control in the active child form (and thats good). But when i press Ctrl+Tab and the focus is on the textbox it enter a Tab character into the textbox (which I don't want), and move to the next child form. what i want is move to the next child form when pressing Ctrl+Tab without entering a Tab character into the textbox. thanx in advance.HatemGamal

1 Answers

1
votes

Well, if you want to suppress Ctrl+Tab press event in textbox, you may hanlde TextBox.KeyDown event with code like this:

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

This code will suppress Tab behaviour in TextBox. But I don't know if it keeps child forms switching behaviour. Possibly you will have to implement it programmatically. In my simple MDI application with one MDIContainer form and two child forms showed this behaviour doesn't appear by default.