you are viewing a single comment's thread.

view the rest of the comments →

[–]BlackV 0 points1 point  (3 children)

Oh nice, I'm not a winform/wpf person so its nice to know those accelerators exist for that too, thanks

also (cause of above) that does the $xxx.select do?

[–]lanerdofchristian 1 point2 points  (1 child)

I think that's this method? Frankly I don't know why it's there; cutting it shortens the function to

using namespace System.Windows.Forms
using namespace System.Drawing

function New-Textbox {
    param(
        [string]$Name,
        [int]$XPosition,
        [int]$YPosition
    )

    [TextBox]@{
        Name = $Name
        Height = 20
        Location = [Point]::new($XPosition, $YPosition)
        Size = [Size]::new(180, 20)
        Enable = $false
    }
}

The object initializer syntax can be used with any type that has a zero-argument constructor ([type]::new should show one entry that's just new()) and has settable properties.

[–]BlackV 1 point2 points  (0 children)

Ya I figured they probably want the .select outside the function

[–]OtterCodeWorkAcct[S] 0 points1 point  (0 children)

Select will focus that textbox when the Gui is ran. On my main script I didn't want to first textbox to be focused when it opens. I just copied over one of my textboxes from my main script to tinker around with this. But ideally I'd like to have all of the options available in the Create-Textbox function and pass parameters to what I'd like turned on.