Hi,
I am having trouble with the passing listbox items to display in a textbox.
Firstly Please create a folder on called C:\Test and add a couple of .txt files in the folder. When executing the below script you will see the text file get populated within the listbox.
Now I need the script to do the following: When an item is selected in the list box it goes and gets the content from within the file C:\Test\(filename selected in the listbox) and display the content in the text box.
Help would be appreciated :)
$objForm = New-Object System.Windows.Forms.Form
$objForm.Text = "Select a Computer"
$objForm.Size = New-Object System.Drawing.Size(500,700)
$objForm.StartPosition = "CenterScreen"
$objForm.Text = "Test"
$objListBox = New-Object System.Windows.Forms.ListBox
$objListBox.Location = New-Object System.Drawing.Size(10,70)
$objListBox.Size = New-Object System.Drawing.Size(260,30)
$objListBox.Height = 250
$objForm.Controls.Add($objListBox)
$objTextBox = New-Object System.Windows.Forms.TextBox
$objTextBox.Location = New-Object System.Drawing.Size(10,400)
$objTextBox.Size = New-Object System.Drawing.Size(400,3000)
$objtextBox.Height = 200
$objtextBox.Multiline = $true
$objForm.Controls.Add($objtextBox)
# Populate list.
Get-ChildItem -Path C:/Test -Recurse -Include *.txt | ForEach-Object {[void] $objListBox.Items.Add($_)}
$objForm.ShowDialog()