Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Forms PowerShell Form大楼_Forms_Powershell_Scripting_Textbox - Fatal编程技术网

Forms PowerShell Form大楼

Forms PowerShell Form大楼,forms,powershell,scripting,textbox,Forms,Powershell,Scripting,Textbox,我已经为运行新ADUser和添加AdGroupMember构建了一个非常基本的表单 现在我把它保存为psm1中的函数 您将在powershell窗口顶部显示PS type函数名和表单加载。到现在为止,一直都还不错。但是我使用它的用户希望我自动激活Textbox1字段中的光标 任何对我可以找到的信息有想法的人?将焦点设置在文本框对象上: $textbox.Focus() $textBox=New Object System.Windows.Forms.textBox$textBox.Locati

我已经为运行新ADUser和添加AdGroupMember构建了一个非常基本的表单

现在我把它保存为psm1中的函数

您将在powershell窗口顶部显示PS type函数名和表单加载。到现在为止,一直都还不错。但是我使用它的用户希望我自动激活Textbox1字段中的光标


任何对我可以找到的信息有想法的人?

将焦点设置在文本框对象上:

$textbox.Focus()

$textBox=New Object System.Windows.Forms.textBox$textBox.Location=New Object System.Drawing.Point(10,40)$textBox.Size=New Object System.Drawing.Size(150,20)$textBox.CharacterCasing=“Normal”$textBox.Focused()$form.Controls.Add($textBox)工作起来很有魅力。这东西太棒了,我只需要学习术语的mroe,这样谷歌fu就更容易了。非常感谢。我要说的是,它在作为ps1从ISE执行时起作用,但当我作为函数psm1运行它时,它没有切换焦点。您可能需要将
$textbox.focus()
添加到表单加载事件中,以便表单加载后立即切换焦点。
$form.add\u loaded({$textbox.focus()})