Neu organisiert für neues Schuljahr
This commit is contained in:
53
11fi5/powershell/datagridview.ps1
Normal file
53
11fi5/powershell/datagridview.ps1
Normal file
@ -0,0 +1,53 @@
|
||||
Add-Type -AssemblyName System.Windows.Forms
|
||||
[System.Windows.Forms.Application]::EnableVisualStyles()
|
||||
|
||||
$Form = New-Object system.Windows.Forms.Form
|
||||
$Form.ClientSize = '686,420'
|
||||
$Form.text = "Form"
|
||||
$Form.TopMost = $false
|
||||
|
||||
$DataGridView1 = New-Object system.Windows.Forms.DataGridView
|
||||
$DataGridView1.width = 454
|
||||
$DataGridView1.height = 377
|
||||
$DataGridView1.location = New-Object System.Drawing.Point(208,18)
|
||||
|
||||
$Button1 = New-Object system.Windows.Forms.Button
|
||||
$Button1.text = "Datei einlesen"
|
||||
$Button1.width = 176
|
||||
$Button1.height = 376
|
||||
$Button1.location = New-Object System.Drawing.Point(22,18)
|
||||
$Button1.Font = 'Microsoft Sans Serif,10'
|
||||
|
||||
$Form.controls.AddRange(@($DataGridView1,$Button1))
|
||||
|
||||
$Column1 = New-Object System.Windows.Forms.DataGridViewTextboxColumn
|
||||
$Column2 = New-Object System.Windows.Forms.DataGridViewTextboxColumn
|
||||
$Column3 = New-Object System.Windows.Forms.DataGridViewTextboxColumn
|
||||
$Column1.Width = 128
|
||||
$Column2.Width = 128
|
||||
$Column3.Width = 128
|
||||
|
||||
$Column1.Name = 'Kundennummer'
|
||||
$Column2.Name = 'Vorname'
|
||||
$Column3.Name = 'Nachname'
|
||||
$DataGridView1.Columns.Add($Column1)
|
||||
$DataGridView1.Columns.Add($Column2)
|
||||
$DataGridView1.Columns.Add($Column3)
|
||||
|
||||
$Form.Controls.AddRange(($DataGridView1))
|
||||
|
||||
$Button1.add_click(
|
||||
{
|
||||
$DataGridView1.Rows.Clear()
|
||||
$file = Get-Content -Path "kunden.txt"
|
||||
foreach ($line in $file)
|
||||
{
|
||||
$num = $line.split(";")[0]
|
||||
$vname = $line.split(";")[1]
|
||||
$nname = $line.split(";")[2]
|
||||
$DataGridView1.Rows.Add($num,$vname,$nname)
|
||||
}
|
||||
})
|
||||
|
||||
Clear-Host
|
||||
$Form.ShowDialog()
|
||||
Reference in New Issue
Block a user