0
我有一個格式爲datagridview
。在這datagridview
的第一列是CheckBoxColumn
。我正在嘗試在第一列的標題中添加一個複選框,以充當所有下方複選框的選擇。我無法理解我在網上找到的C#示例,我還沒有找到任何PowerShell示例。有人能指出我如何做到這一點的正確方向嗎?在數據格式視圖中將複選框添加到頁眉單元
[void] [System.Reflection.Assembly]::LoadWithPartialName(「System.Windows.Forms」)
[void] [System.Reflection.Assembly]::LoadWithPartialName(「System.Drawing」)
$form = New-Object System.Windows.Forms.Form
$form.Size = New-Object System.Drawing.Size(400, 400)
$form.KeyPreview = $true
$CheckBoxColumn1 = New-object System.Windows.Forms.DataGridViewCheckBoxColumn
$CheckBoxColumn1.Width = 30
$CheckBoxColumn1.ReadOnly = $false
$DataGrid1 = New-Object System.Windows.Forms.DataGridView
$DataGrid1.Dock = "Fill"
$DataGrid1.BorderStyle = 'FixedSingle'
$DataGrid1.AlternatingRowsDefaultCellStyle.BackColor = 'LightGray'
$DataGrid1.AllowUserToAddRows = $false
$DataGrid1.RowHeadersVisible = $false
$DataGrid1.BackgroundColor = "White"
$DataGrid1.Columns.Add($CheckBoxColumn1) | Out-Null
$DataGrid1.ColumnCount = 3
$DataGrid1.Columns[1].name = 'col1'
$DataGrid1.Columns[2].name = 'col2'
$DataGrid1.Rows.add($false,'one','two')
$DataGrid1.Rows.add($false,'three','four')
##Add checkbox to header row column 0
$form.Controls.Add($DataGrid1)
$form.ShowDialog()