2021-05-17 Aufgaben
This commit is contained in:
53
powershell/datagridview.ps1
Normal file
53
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)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
cls
|
||||||
|
$Form.ShowDialog()
|
||||||
2
powershell/kunden.txt
Normal file
2
powershell/kunden.txt
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
1;Albert;Friedel
|
||||||
|
2;Hans;Fritz
|
||||||
125
powershell/ps-form.ps1
Normal file
125
powershell/ps-form.ps1
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
Add-Type -AssemblyName System.Windows.Forms
|
||||||
|
|
||||||
|
$form = New-Object System.Windows.Forms.Form -Property @{
|
||||||
|
Text = 'Data Entry Form'
|
||||||
|
Size = New-Object System.Drawing.Size(690,380)
|
||||||
|
StartPosition = 'CenterScreen'
|
||||||
|
}
|
||||||
|
|
||||||
|
$groupbox = New-Object System.Windows.Forms.GroupBox -Property @{
|
||||||
|
Location = New-Object System.Drawing.Point(8,0)
|
||||||
|
Size = New-Object System.Drawing.Size(350,300)
|
||||||
|
Text = "Group Box"
|
||||||
|
}
|
||||||
|
|
||||||
|
$textBoxVorname = New-Object System.Windows.Forms.TextBox -Property @{
|
||||||
|
Location = New-Object System.Drawing.Point(($groupbox.Width-120-8), 40)
|
||||||
|
Size = New-Object System.Drawing.Size(120,20)
|
||||||
|
}
|
||||||
|
|
||||||
|
$textBoxName = New-Object System.Windows.Forms.TextBox -Property @{
|
||||||
|
Location = New-Object System.Drawing.Point(($groupbox.Width-120-8), 68)
|
||||||
|
Size = New-Object System.Drawing.Size(120,20)
|
||||||
|
}
|
||||||
|
|
||||||
|
$labelWidth = 50
|
||||||
|
|
||||||
|
$labelVorname = New-Object System.Windows.Forms.Label -Property @{
|
||||||
|
Text = "Vorname"
|
||||||
|
Location = New-Object System.Drawing.Point(($groupbox.Width-120-$labelWidth-16), $textBoxVorname.Top)
|
||||||
|
Size = New-Object System.Drawing.Size($labelWidth,20)
|
||||||
|
TextAlign = 64
|
||||||
|
}
|
||||||
|
|
||||||
|
$labelName = New-Object System.Windows.Forms.Label -Property @{
|
||||||
|
Text = "Name"
|
||||||
|
Location = New-Object System.Drawing.Point(($groupbox.Width-120-$labelWidth-16), $textBoxName.Top)
|
||||||
|
Size = New-Object System.Drawing.Size($labelWidth,20)
|
||||||
|
TextAlign = 64
|
||||||
|
}
|
||||||
|
|
||||||
|
$attributeDistance = 24
|
||||||
|
$marginBottom = 8
|
||||||
|
|
||||||
|
$checkBoxAzubi = New-Object System.Windows.Forms.CheckBox -Property @{
|
||||||
|
Text = "Azubi"
|
||||||
|
Location = New-Object System.Drawing.Point(8, ($groupbox.Height - $marginBottom - $attributeDistance*4))
|
||||||
|
Size = New-Object System.Drawing.Size(80,20)
|
||||||
|
TextAlign = 16
|
||||||
|
}
|
||||||
|
|
||||||
|
$radioSingle = New-Object System.Windows.Forms.RadioButton -Property @{
|
||||||
|
Text = "Single"
|
||||||
|
Location = New-Object System.Drawing.Point(8, ($groupbox.Height - $marginBottom - $attributeDistance*3))
|
||||||
|
Size = New-Object System.Drawing.Size(80,20)
|
||||||
|
TextAlign = 16
|
||||||
|
}
|
||||||
|
|
||||||
|
$radioVergeben = New-Object System.Windows.Forms.RadioButton -Property @{
|
||||||
|
Text = "Vergeben"
|
||||||
|
Location = New-Object System.Drawing.Point(8, ($groupbox.Height - $marginBottom - $attributeDistance*2))
|
||||||
|
Size = New-Object System.Drawing.Size(80,20)
|
||||||
|
TextAlign = 16
|
||||||
|
}
|
||||||
|
|
||||||
|
$comboBox = New-Object System.Windows.Forms.ComboBox -Property @{
|
||||||
|
Text = "comboBox"
|
||||||
|
Location = New-Object System.Drawing.Point(8, ($groupbox.Height - $marginBottom - $attributeDistance*1))
|
||||||
|
Size = New-Object System.Drawing.Size(120,20)
|
||||||
|
}
|
||||||
|
|
||||||
|
$picture = New-Object System.Windows.Forms.PictureBox -Property @{
|
||||||
|
Location = New-Object System.Drawing.Point(8, 16)
|
||||||
|
Size = New-Object System.Drawing.Size(($groupbox.Width-200-24), ($groupbox.Height - $marginBottom - $attributeDistance*4 - 24))
|
||||||
|
SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::AutoSize
|
||||||
|
BackgroundImage = [System.Drawing.Image]::FromFile("C:\Users\krume\OneDrive - Klara-Oppenheimer-Schule\neuland logo.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
$groupbox.Controls.AddRange($($textBoxVorname, $textBoxName, $labelVorname, $labelName, $checkBoxAzubi, $radioSingle, $radioVergeben, $comboBox, $picture))
|
||||||
|
|
||||||
|
$form.Controls.Add($groupbox)
|
||||||
|
|
||||||
|
$listBox = New-Object System.Windows.Forms.ListBox -Property @{
|
||||||
|
Location = New-Object System.Drawing.Point(($groupbox.Width + $groupbox.Left + 8), 8)
|
||||||
|
Size = New-Object System.Drawing.Size(300, 300)
|
||||||
|
}
|
||||||
|
|
||||||
|
$button = New-Object System.Windows.Forms.Button -Property @{
|
||||||
|
Text = "Knopf"
|
||||||
|
Location = New-Object System.Drawing.Point(($listBox.Left + $listBox.Width - 100), 302)
|
||||||
|
Size = New-Object System.Drawing.Size(100, 30)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$form.Controls.Add($listBox)
|
||||||
|
$form.Controls.Add($button)
|
||||||
|
|
||||||
|
# $okButton = New-Object System.Windows.Forms.Button
|
||||||
|
# $okButton.Location = New-Object System.Drawing.Point(75,120)
|
||||||
|
# $okButton.Size = New-Object System.Drawing.Size(75,23)
|
||||||
|
# $okButton.Text = 'OK'
|
||||||
|
# $okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
|
||||||
|
# $form.AcceptButton = $okButton
|
||||||
|
# $form.Controls.Add($okButton)
|
||||||
|
|
||||||
|
# $cancelButton = New-Object System.Windows.Forms.Button
|
||||||
|
# $cancelButton.Location = New-Object System.Drawing.Point(150,120)
|
||||||
|
# $cancelButton.Size = New-Object System.Drawing.Size(75,23)
|
||||||
|
# $cancelButton.Text = 'Cancel'
|
||||||
|
# $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
|
||||||
|
# $form.CancelButton = $cancelButton
|
||||||
|
# $form.Controls.Add($cancelButton)
|
||||||
|
|
||||||
|
# $label = New-Object System.Windows.Forms.Label
|
||||||
|
# $label.Location = New-Object System.Drawing.Point(10,20)
|
||||||
|
# $label.Size = New-Object System.Drawing.Size(280,20)
|
||||||
|
# $label.Text = 'Please enter the information in the space below:'
|
||||||
|
# $form.Controls.Add($label)
|
||||||
|
|
||||||
|
# $textBox = New-Object System.Windows.Forms.TextBox
|
||||||
|
# $textBox.Location = New-Object System.Drawing.Point(10,40)
|
||||||
|
# $textBox.Size = New-Object System.Drawing.Size(260,20)
|
||||||
|
# $form.Controls.Add($textBox)
|
||||||
|
|
||||||
|
$form.Topmost = $true
|
||||||
|
$form.ShowDialog()
|
||||||
Reference in New Issue
Block a user