Multiple textbox; how to select the right textbox?

by Apr 24, 2020

I'm looking for help with my textboxes.

I manage to create them a certain number according to a variable, but I cannot select or retrieve the value of this or that texbox.


once my textboxes are created, they are in deactivated mode; I want the first to be active in order to write in it and the next to activate in turn as soon as in the previous textbox I have at least 5 characters present.

Thank you in advance for your assistance.


#region createtextbox
$u = 1
$u1 = 30
$nbuser = 10
for ($u = 0; $u -lt $nbuser; $u++)
	$textboxuser = New-Object System.Windows.Forms.TextBox
	$textboxuser.Location = New-Object System.Drawing.Size(16, $u1);
	$textboxuser.Name = '$textboxuser' + $u;
	$textboxuser.Text = $;
	$textboxuser.Size = New-Object System.Drawing.Size (200, 20);
	$textboxuser.Enabled = $false;
	$u1 = $u1 + 30

$u = 1
#I want the fisrt textbox...
$textboxuser.Enabled= $true

#endregion SuivantversONGLET

#region ONGLET
$u = 1
$textboxuser_TextChanged = {
	$textboxuser = '$textboxuser'+$u
	$textboxuser.Enabled = $true

#endregion createtextbox