0

Been doing a little bit of research on this and cant find a powershell answer, I need to change focus of one textbox to another when it is full. Example when inputting a phone number instead of having to press Tab after the area code it would shift focus to the next set. Below is what I have so far

`$Textbox9 = New-Object Systems.Windows.Forms.Textbox
 $Textbox9.MaxLength = 3
 $Textbox9.Location = '635,220'
 $Textbox9.Size = '40,20'
 $Textbox9.Name =
 $Textbox9.Text =
 $Form.Controls.Add($Textbox9)
 If ($Textbox9.Text.Length = 3){
     $Textbox10.SetFocus} `
Slyons
  • 117
  • 4
  • 20

1 Answers1

0

You can register to the TextChanged event. Once TextBox9 reached the max size it switches to Textbox10.

This should work:

$action = { if ($Textbox9.Text.Length -eq 3){
     $Textbox10.focus()} }
$Textbox9.Add_TextChanged($action)
Fabian
  • 1,886
  • 14
  • 13