'Formatting textbox contents
i'm trying to create a gui script for our helpdesk to use to grant users share permissions. I'm currently stuck at textbox with share paths, i want it to accept input, upon "Textchange" event, validate paths and then change text so only valid paths are left and invalid ones would be deleted. The event looks like this:
$Pathbox.Add_Textchanged({
#$PathsToGrant = @()
$this.Text -split '\r?\n' -ne '' | ForEach-Object {
if ($_ -match "C:" -or $_ -match "ProgramFile" -or $_ -match "D:" -or $_ -match "Appdata")
{
$msgboxinput =[System.Windows.Messagebox]::Show("Some text",'Warning','Ok','Warning')
$mod = "(0,666)"
}
elseif (-not$(Test-Path -Path $_))
{
$msgboxinput =[System.Windows.Messagebox]::Show("Some Text",'Warning','Ok','Warning')
$mod = "(0,666)"
}
else
{
$PathsToGrant += $_
#Write-Host $PathsToGrant
}
}
Write-Host $PathsToGrant.Count
$PathBox.Text = ""
$PathBox.Text = $PathsToGrant
})
I've been adviced here to use $this.Text -split '\r?\n' -ne '' so my textbox would behave like an array instead of 1 long string, but when i try to rewrite the Textbox's text at the end with legit values - it just inserts 2 array objects as 1 row anyway and it creates broken cycle. Maybe i should not have used textbox control in the firt place ? Are there any other more suitable controls for theese kinds of things ? Thank You.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
