tags:

views:

14

answers:

1

I have Five textboxes as part of a grid.

<TextBox Name="A1" MaxLength="1" ></TextBox>
<TextBox Name="A2" MaxLength="1" ></TextBox>
<TextBox Name="A3" MaxLength="1" ></TextBox>
<TextBox Name="A4" MaxLength="1" ></TextBox>
<TextBox Name="A5" MaxLength="1" ></TextBox>

Initially cursor will be focused at A1 using the command A1.Focus(). As soon as a character is entered in A1, I want the focus to be changed to A2 and then to A3 etc. [I can enter a 5 letter word into these textboxes without pressing Tab or Enter]

How can this be done in WPF C# Code.

A: 

You can use the KeyDonw event and if the key is a letter then you can change the focus.

<TextBox KeyDown="On_Key_Down"/>

...

On_Key_Down(object Sender, KeyEventArgs E)
{
    A2.Focus();
}
Pavel Nikolov