Forms text box autocomplete, new autocmplete after comma

Brass Contributor

I want to do an autofill function, that when you type in some letters matching to some name it will show suggestion BUT if you press comma and separate the values with it, a new autofill should start.

Script is like following:

$form_Users = New-Object System.Windows.Forms.Form
$form_Users.Text = "Type in the Users that need to be added"
$form_Users.Size = New-Object System.Drawing.Size (300,200)
$form_Users.StartPosition = "CenterScreen"

$okButton_Users = New-Object System.Windows.Forms.Button
$okButton_Users.Location = New-Object System.Drawing.Point (75,120)
$okButton_Users.Size = New-Object System.Drawing.Size (75,23)
$okButton_Users.Text = "OK"
$okButton_Users.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form_Users.AcceptButton = $okButton_Users
$form_Users.Controls.Add($okButton_Users)

$cancelButton_Users = New-Object System.Windows.Forms.Button
$cancelButton_Users.Location = New-Object System.Drawing.Point (150,120)
$cancelButton_Users.Size = New-Object System.Drawing.Size (75,23)
$cancelButton_Users.Text = "Cancel"
$cancelButton_Users.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form_Users.CancelButton = $cancelButton_Users
$form_Users.Controls.Add($cancelButton_Users)
                                 
$label_Users_top = New-Object System.Windows.Forms.Label
$label_Users_top.Location = New-Object System.Drawing.Point (10,20)
$label_Users_top.Size = New-Object System.Drawing.Size (280,20)
$label_Users_top.Text = "Please enter the names in the space below:"
$form_Users.Controls.Add($label_Users_top)

$label_Users_bottom = New-Object System.Windows.Forms.Label
$label_Users_bottom.Location = New-Object System.Drawing.Point (10,65)
$label_Users_bottom.Size = New-Object System.Drawing.Size (280,20)
$label_Users_bottom.Text = "For example: Max Mustermann,Jon Doe"
$form_Users.Controls.Add($label_Users_bottom)

$label_Users_bottom = New-Object System.Windows.Forms.Label
$label_Users_bottom.Location = New-Object System.Drawing.Point (10,85)
$label_Users_bottom.Size = New-Object System.Drawing.Size (280,20)
$label_Users_bottom.Text = "Note: NO spaces between the Names"
$form_Users.Controls.Add($label_Users_bottom)

$textBox_Users = New-Object System.Windows.Forms.TextBox
$textBox_Users.Location = New-Object System.Drawing.Point (10,40)
$textBox_Users.Size = New-Object System.Drawing.Size (260,20)
$textBox_Users.AutoCompleteSource = "CustomSource"
$textBox_Users.AutoCompleteMode = "SuggestAppend"
$textBox_Users.AutoCompleteCustomSource = $autocomplete
"jon does","max muster" | % {$textBox_Users.AutoCompleteCustomSource.AddRange($_)}
$form_Users.Controls.Add($textBox_Users)

$form_Users.TopMost = $true

$form_Users.Add_Shown({$textBox_Users.Select()})
$form_Users.ShowDialog()

 Eventually I want to get Users out of the AD and create the autofill-source with it, but this is a different story.

BUT you still need to be able to type in multiple names and still get the suggestion. Seperator is a comma.

 

Greetings

Yannik Schulz

0 Replies