0

I'm trying to make arrays which lead to different files on my computer. Then I want to display the arrays in a check box, so I can just click and open my files from there. The array can be static, but would be nice if I could add new stuff dynamically.

$menulist.DataBindings.DefaultDataSourceUpdateMode = 0
$menulist.FormattingEnabled = $True
$System_Drawing_Point = New-Object System.Drawing.Point
$System_Drawing_Point.X = 12
$System_Drawing_Point.Y = 24
$menulist.Location = $System_Drawing_Point
$menulist.Name = "menulist"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Height = 328
$System_Drawing_Size.Width = 235
$TemplateArray = $template1,$template2;
$template1 = Get-ChildItem -Path C:\Users\$Env:USERNAME\Documents\test.tx
$template2 = Get-ChildItem -Path C:\Users\$Env:USERNAME\Documents\test2.txt
$menulist.Items.AddRange($TemplateArray)
$menulist.Size = $System_Drawing_Size
$menulist.TabIndex = 7
6
  • Where is your $Form.ShowDialog(); or something similar? stackoverflow.com/a/21009953/897326 Generally speaking, when it comes to showing forms, you should consider switching to C#/WinForms app, because it's much more simple over there, and you are using .NET anyway, whether from Powershell or C#, the only difference is syntax simplicity, and Visual Studio which helps you build. Commented Jan 24, 2016 at 14:03
  • at the very top. This is just the checklist section. Thank you for the link. That's how I started out. But if try to "link" the arrays, it doesn't show them anymore. Commented Jan 24, 2016 at 14:04
  • Can you post the whole code section? Then we'd be able to copy/paste to our favorite editor here and give it a try. $TemplateArray = $template1,$template2; <-- this does not make much sense to me, especially since you (re)define $template1,$template2; after. Commented Jan 24, 2016 at 14:05
  • Code in Pastebin here you go Commented Jan 24, 2016 at 14:08
  • This is pure winforms, why can't you go with plain old C# WinForms app? In other words, why do you need Powershell? BTW, you posted code, what is the problem with it? You never specified. Commented Jan 24, 2016 at 14:13

1 Answer 1

0

While we are still discussing what you need, I'll take a guess:

$TemplateArray = $template1,$template2;
$template1 = Get-ChildItem -Path C:\Users\$Env:USERNAME\Documents\test.tx
$template2 = Get-ChildItem -Path C:\Users\$Env:USERNAME\Documents\test2.txt

Notice above - $template1 and $template2 are used before they are declared. You probably get two empty strings in it. Instead, initialize variables first:

$template1 = Get-ChildItem -Path C:\Users\$Env:USERNAME\Documents\test.tx
$template2 = Get-ChildItem -Path C:\Users\$Env:USERNAME\Documents\test2.txt
$TemplateArray = $template1,$template2;
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! Seems like thats what caused it to not to be displayed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.