Forms text box autocomplete, new autocmplete after comma

%3CLINGO-SUB%20id%3D%22lingo-sub-2168370%22%20slang%3D%22en-US%22%3EForms%20text%20box%20autocomplete%2C%20new%20autocmplete%20after%20comma%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2168370%22%20slang%3D%22en-US%22%3E%3CP%3EI%20want%20to%20do%20an%20autofill%20function%2C%20that%20when%20you%20type%20in%20some%20letters%20matching%20to%20some%20name%20it%20will%20show%20suggestion%20BUT%20if%20you%20press%20comma%20and%20separate%20the%20values%20with%20it%2C%20a%20new%20autofill%20should%20start.%3C%2FP%3E%3CP%3EScript%20is%20like%20following%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24form_Users%20%3D%20New-Object%20System.Windows.Forms.Form%0A%24form_Users.Text%20%3D%20%22Type%20in%20the%20Users%20that%20need%20to%20be%20added%22%0A%24form_Users.Size%20%3D%20New-Object%20System.Drawing.Size%20(300%2C200)%0A%24form_Users.StartPosition%20%3D%20%22CenterScreen%22%0A%0A%24okButton_Users%20%3D%20New-Object%20System.Windows.Forms.Button%0A%24okButton_Users.Location%20%3D%20New-Object%20System.Drawing.Point%20(75%2C120)%0A%24okButton_Users.Size%20%3D%20New-Object%20System.Drawing.Size%20(75%2C23)%0A%24okButton_Users.Text%20%3D%20%22OK%22%0A%24okButton_Users.DialogResult%20%3D%20%5BSystem.Windows.Forms.DialogResult%5D%3A%3AOK%0A%24form_Users.AcceptButton%20%3D%20%24okButton_Users%0A%24form_Users.Controls.Add(%24okButton_Users)%0A%0A%24cancelButton_Users%20%3D%20New-Object%20System.Windows.Forms.Button%0A%24cancelButton_Users.Location%20%3D%20New-Object%20System.Drawing.Point%20(150%2C120)%0A%24cancelButton_Users.Size%20%3D%20New-Object%20System.Drawing.Size%20(75%2C23)%0A%24cancelButton_Users.Text%20%3D%20%22Cancel%22%0A%24cancelButton_Users.DialogResult%20%3D%20%5BSystem.Windows.Forms.DialogResult%5D%3A%3ACancel%0A%24form_Users.CancelButton%20%3D%20%24cancelButton_Users%0A%24form_Users.Controls.Add(%24cancelButton_Users)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%24label_Users_top%20%3D%20New-Object%20System.Windows.Forms.Label%0A%24label_Users_top.Location%20%3D%20New-Object%20System.Drawing.Point%20(10%2C20)%0A%24label_Users_top.Size%20%3D%20New-Object%20System.Drawing.Size%20(280%2C20)%0A%24label_Users_top.Text%20%3D%20%22Please%20enter%20the%20names%20in%20the%20space%20below%3A%22%0A%24form_Users.Controls.Add(%24label_Users_top)%0A%0A%24label_Users_bottom%20%3D%20New-Object%20System.Windows.Forms.Label%0A%24label_Users_bottom.Location%20%3D%20New-Object%20System.Drawing.Point%20(10%2C65)%0A%24label_Users_bottom.Size%20%3D%20New-Object%20System.Drawing.Size%20(280%2C20)%0A%24label_Users_bottom.Text%20%3D%20%22For%20example%3A%20Max%20Mustermann%2CJon%20Doe%22%0A%24form_Users.Controls.Add(%24label_Users_bottom)%0A%0A%24label_Users_bottom%20%3D%20New-Object%20System.Windows.Forms.Label%0A%24label_Users_bottom.Location%20%3D%20New-Object%20System.Drawing.Point%20(10%2C85)%0A%24label_Users_bottom.Size%20%3D%20New-Object%20System.Drawing.Size%20(280%2C20)%0A%24label_Users_bottom.Text%20%3D%20%22Note%3A%20NO%20spaces%20between%20the%20Names%22%0A%24form_Users.Controls.Add(%24label_Users_bottom)%0A%0A%24textBox_Users%20%3D%20New-Object%20System.Windows.Forms.TextBox%0A%24textBox_Users.Location%20%3D%20New-Object%20System.Drawing.Point%20(10%2C40)%0A%24textBox_Users.Size%20%3D%20New-Object%20System.Drawing.Size%20(260%2C20)%0A%24textBox_Users.AutoCompleteSource%20%3D%20%22CustomSource%22%0A%24textBox_Users.AutoCompleteMode%20%3D%20%22SuggestAppend%22%0A%24textBox_Users.AutoCompleteCustomSource%20%3D%20%24autocomplete%0A%22jon%20does%22%2C%22max%20muster%22%20%7C%20%25%20%7B%24textBox_Users.AutoCompleteCustomSource.AddRange(%24_)%7D%0A%24form_Users.Controls.Add(%24textBox_Users)%0A%0A%24form_Users.TopMost%20%3D%20%24true%0A%0A%24form_Users.Add_Shown(%7B%24textBox_Users.Select()%7D)%0A%24form_Users.ShowDialog()%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3BEventually%20I%20want%20to%20get%20Users%20out%20of%20the%20AD%20and%20create%20the%20autofill-source%20with%20it%2C%20but%20this%20is%20a%20different%20story.%3C%2FP%3E%3CP%3EBUT%20you%20still%20need%20to%20be%20able%20to%20type%20in%20multiple%20names%20and%20still%20get%20the%20suggestion.%20Seperator%20is%20a%20comma.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGreetings%3C%2FP%3E%3CP%3EYannik%20Schulz%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2168370%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
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