Handle the TextBox.KeyPress event.
In the event, check the existing text, and modify if necessary.
private void myTextBox_KeyPress(object sender, KeyPressEventArgs e)
{
TextBox tb = sender as TextBox;
if (tb != null)
{
string existing = tb.Text;
if (existing.Length >= 7)
{
tb.Text = existing.Substring(existing.Length - 6);
tb.SelectionStart = tb.Text.Length;
}
}
}