我不明白为什么我的GroupBox没有显示。 我想显示带有多个标签的groupbox,但它不起作用。 我试图用标签代替radiobuttons,代码在这里=> https://sysadminemporium.wordpress.com/2012/12/07/powershell-gui-for-your-scripts-episode-3/ 我是GUI的初学者,我见过其他例子,但我不能按照我的意愿使用这个代码。 这是我的代码:
#----------------------------------------------
# Generated Form Function
#----------------------------------------------
function Call-test_psf {
#----------------------------------------------
#region Import the Assemblies
#----------------------------------------------
[void][reflection.assembly]::Load('System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
[void][reflection.assembly]::Load('System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
#endregion Import Assemblies
#----------------------------------------------
#region Generated Form Objects
#----------------------------------------------
[System.Windows.Forms.Application]::EnableVisualStyles()
$form1 = New-Object 'System.Windows.Forms.Form'
$form1.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedDialog
$form1.MaximizeBox = $False
$form1.MinimizeBox = $False
# Choix du titre
$form1.Text = "Title"
$label4 = New-Object 'System.Windows.Forms.Label'
$label5 = New-Object 'System.Windows.Forms.Label'
#endregion Generated Form Objects
#----------------------------------------------
# User Generated Script
#----------------------------------------------
$form1_Load={
#TODO: Initialize Form Controls here
}
# --End User Generated Script--
#----------------------------------------------
#region Generated Events
#----------------------------------------------
$Form_StateCorrection_Load=
{
#Correct the initial state of the form to prevent the .Net maximized form issue
$form1.WindowState = $InitialFormWindowState
}
$Form_Cleanup_FormClosed=
{
#Remove all event handlers from the controls
try
{
$buttonSuivant.remove_Click($buttonSuivant_Click)
$buttonRetour.remove_Click($buttonRetour_Click)
$form1.remove_Load($form1_Load)
$form1.remove_Load($Form_StateCorrection_Load)
$form1.remove_FormClosed($Form_Cleanup_FormClosed)
}
catch [Exception]
{ }
}
#endregion Generated Events
#----------------------------------------------
#region Generated Form Code
#----------------------------------------------
$form1.SuspendLayout()
#
# form1
#
$form1.Controls.Add($groupBox1)
$form1.ClientSize = '700, 300'
#endregion
$form1.Name = 'form1'
$form1.Text = 'Title'
$form1.add_Load($form1_Load)
#
# GroupBox1
#
$groupBox1 = New-Object System.Windows.Forms.GroupBox
$groupBox1.Location = '150,300'
$groupBox1.size = '400,150'
$groupBox1.text = "Title groupBox1"
$groupBox1.Visible = $true
#
# progressBar1
#
$progressBar1 = New-Object System.Windows.Forms.ProgressBar
$progressBar1.Name = 'progressBar1'
$progressBar1.Value = 0
$progressBar1.Style="Continuous"
$System_Drawing_Size = New-Object System.Drawing.Size
$System_Drawing_Size.Width = $width - 40
$System_Drawing_Size.Height = 20
$progressBar1.Size = $System_Drawing_Size
$progressBar1.Left = 5
$progressBar1.Top = 40
#
# label4
#
$label4.Font = 'Microsoft Sans Serif, 8pt'
$label4.Location = '50, 50'
$label4.Name = 'label2'
$label4.Size = '20, 20'
$label4.TabIndex = 8
$label4.TextAlign = 'TopLeft'
$label4.Visible = $false
$label4.Text = "test"
#
# label5
#
$label5.Font = 'Microsoft Sans Serif, 8pt'
$label5.Location = '50, 70'
$label5.Name = 'label2'
$label5.Size = '20, 20'
$label5.TabIndex = 10
$label5.TextAlign = 'TopLeft'
$label5.Visible = $false
$label5.Text = "test"
$groupBox1.Controls.AddRange(@($Label4,$Label5))
#
$form1.ResumeLayout()
#endregion Generated Form Code
#----------------------------------------------
#Save the initial state of the form
$InitialFormWindowState = $form1.WindowState
#Init the OnLoad event to correct the initial state of the form
$form1.add_Load($Form_StateCorrection_Load)
#Clean up the control events
$form1.add_FormClosed($Form_Cleanup_FormClosed)
#Show the Form
return $form1.ShowDialog()
} #End Function
#Call the form
Call-test_psf | Out-Null
你能帮帮我吗?
提前谢谢。
答案 0 :(得分:2)
更改2行:
var req = {
"method": "POST",
"url": "https://api.ionic.io/push/notifications",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer " + token
},
"body": {
"tokens": ["........"],
"profile": "pushserver",
"notification": {
"title": title,
"message": message,
"android": {
"title": title,
"message": message
}
}
}
};
y位置为300,位于表单底部,因为它只有300px高。
$groupBox1.Location = '150,300'
在创建组框后将此行移至。所以在$form1.Controls.Add($groupBox1)
之后的任何地方
例如:
$groupBox1 = New-Object System.Windows.Forms.GroupBox