springstil
Goto Top

RadioButton in Powershell abfragen

Hallo zusammen,

ich versuche mir ein kleines Skript zu schreiben was mir auf den Messen die Arbeit erleichtern soll. Und zwar möchte ich gerne Kataloge an Email Adressen Versenden. Gedacht hab ich mir das dass ganze so aussehen soll in etwa 1

Nun war mein Grund Gedanke, die Email so zu verfassen das einfach immer nur die Bausteine eingesetzt werden. Klicke ich also ein Namen an, und dazu eine Preisliste, so würde ich gern einfach die angeklickten Buttons als Variable nutzen um sie dann im Text der als Mail versendet werden soll einzusetzen.

Die RadioButtons habe ich auch einem Panel zugewiesen damit immer nur von beiden eins Aktiv sein kann. Ich ralle es aber absolut nicht wie ich die Anspreche um den richtigen "Check" zu erhalten. Vielleicht kann mir hierbei jemand helfen

function Show-Katalog_Versand_Neu_psf {

	#----------------------------------------------
	#region Import the Assemblies
	#----------------------------------------------
	[void][reflection.assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')  
	[void][reflection.assembly]::Load('System.Drawing, Version=4.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'  
	$labelVertreterAuswählen = New-Object 'System.Windows.Forms.Label'  
	$labelEmailAdresse = New-Object 'System.Windows.Forms.Label'  
	$textbox1 = New-Object 'System.Windows.Forms.TextBox'  
	$labelPreislisten = New-Object 'System.Windows.Forms.Label'  
	$panel2 = New-Object 'System.Windows.Forms.Panel'  
	$radiobuttonSNetto = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonNetto = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonBrutto = New-Object 'System.Windows.Forms.RadioButton'  
	$Ohne = New-Object 'System.Windows.Forms.RadioButton'  
	$panel1 = New-Object 'System.Windows.Forms.Panel'  
	$radiobuttonAndreeSchmidt = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonGasper = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonDirkWidmer = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonRobertBubendorfer = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonStefanReder = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonJörgBehr = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonMarkusScheuerer = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonAlexandraWust = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonRogerGustafsson = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonAchimSeybicke = New-Object 'System.Windows.Forms.RadioButton'  
	$radiobuttonMoritzVonCube = New-Object 'System.Windows.Forms.RadioButton'  
	$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'  
	#endregion Generated Form Objects

	#----------------------------------------------
	# User Generated Script
	#----------------------------------------------
	
	$form1_Load = {
		#TODO: Initialize Form Controls here
		
	}
	
	$panel1_Paint = [System.Windows.Forms.PaintEventHandler]{
		#Event Argument: $_ = [System.Windows.Forms.PaintEventArgs]
		#TODO: Place custom script here
		
	}
	
	$radiobuttonAndreeSchmidt_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonMoritzVonCube_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonStefanReder_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonDirkWidmer_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonAlexandraWust_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonRobertBubendorfer_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonJörgBehr_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonAchimSeybicke_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonGasper_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonRogerGustafsson_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonMarkusScheuerer_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonSNetto_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$Ohne_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonBrutto_CheckedChanged = {
		#TODO: Place custom script here
		
	}
	
	$radiobuttonNetto_CheckedChanged = {
		#TODO: Place custom script 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
		{
			$radiobuttonSNetto.remove_CheckedChanged($radiobuttonSNetto_CheckedChanged)
			$radiobuttonNetto.remove_CheckedChanged($radiobuttonNetto_CheckedChanged)
			$radiobuttonBrutto.remove_CheckedChanged($radiobuttonBrutto_CheckedChanged)
			$Ohne.remove_CheckedChanged($Ohne_CheckedChanged)
			$radiobuttonAndreeSchmidt.remove_CheckedChanged($radiobuttonAndreeSchmidt_CheckedChanged)
			$radiobuttonGasper.remove_CheckedChanged($radiobuttonGasper_CheckedChanged)
			$radiobuttonDirkWidmer.remove_CheckedChanged($radiobuttonDirkWidmer_CheckedChanged)
			$radiobuttonRobertBubendorfer.remove_CheckedChanged($radiobuttonRobertBubendorfer_CheckedChanged)
			$radiobuttonStefanReder.remove_CheckedChanged($radiobuttonStefanReder_CheckedChanged)
			$radiobuttonJörgBehr.remove_CheckedChanged($radiobuttonJörgBehr_CheckedChanged)
			$radiobuttonMarkusScheuerer.remove_CheckedChanged($radiobuttonMarkusScheuerer_CheckedChanged)
			$radiobuttonAlexandraWust.remove_CheckedChanged($radiobuttonAlexandraWust_CheckedChanged)
			$radiobuttonRogerGustafsson.remove_CheckedChanged($radiobuttonRogerGustafsson_CheckedChanged)
			$radiobuttonAchimSeybicke.remove_CheckedChanged($radiobuttonAchimSeybicke_CheckedChanged)
			$radiobuttonMoritzVonCube.remove_CheckedChanged($radiobuttonMoritzVonCube_CheckedChanged)
			$panel1.remove_Paint($panel1_Paint)
			$form1.remove_Load($form1_Load)
			$form1.remove_Load($Form_StateCorrection_Load)
			$form1.remove_FormClosed($Form_Cleanup_FormClosed)
		}
		catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
	}
	#endregion Generated Events

	#----------------------------------------------
	#region Generated Form Code
	#----------------------------------------------
	$form1.SuspendLayout()
	$panel2.SuspendLayout()
	$panel1.SuspendLayout()
	#
	# form1
	#
	$form1.Controls.Add($labelVertreterAuswählen)
	$form1.Controls.Add($labelEmailAdresse)
	$form1.Controls.Add($textbox1)
	$form1.Controls.Add($labelPreislisten)
	$form1.Controls.Add($panel2)
	$form1.Controls.Add($panel1)
	$form1.AutoScaleDimensions = New-Object System.Drawing.SizeF(6, 13)
	$form1.AutoScaleMode = 'Font'  
	$form1.ClientSize = New-Object System.Drawing.Size(636, 462)
	$form1.Name = 'form1'  
	$form1.Text = 'Form'  
	$form1.add_Load($form1_Load)
	#
	# labelVertreterAuswählen
	#
	$labelVertreterAuswählen.AutoSize = $True
	$labelVertreterAuswählen.Font = [System.Drawing.Font]::new('Microsoft Sans Serif', '8.25', [System.Drawing.FontStyle]'Bold')  
	$labelVertreterAuswählen.Location = New-Object System.Drawing.Point(115, 142)
	$labelVertreterAuswählen.Name = 'labelVertreterAuswählen'  
	$labelVertreterAuswählen.Size = New-Object System.Drawing.Size(120, 13)
	$labelVertreterAuswählen.TabIndex = 30
	$labelVertreterAuswählen.Text = 'Vertreter auswählen'  
	#
	# labelEmailAdresse
	#
	$labelEmailAdresse.AutoSize = $True
	$labelEmailAdresse.Location = New-Object System.Drawing.Point(115, 109)
	$labelEmailAdresse.Name = 'labelEmailAdresse'  
	$labelEmailAdresse.Size = New-Object System.Drawing.Size(73, 13)
	$labelEmailAdresse.TabIndex = 29
	$labelEmailAdresse.Text = 'Email Adresse'  
	#
	# textbox1
	#
	$textbox1.Location = New-Object System.Drawing.Point(191, 106)
	$textbox1.Name = 'textbox1'  
	$textbox1.Size = New-Object System.Drawing.Size(146, 20)
	$textbox1.TabIndex = 28
	#
	# labelPreislisten
	#
	$labelPreislisten.AutoSize = $True
	$labelPreislisten.Font = [System.Drawing.Font]::new('Microsoft Sans Serif', '8.25', [System.Drawing.FontStyle]'Bold')  
	$labelPreislisten.Location = New-Object System.Drawing.Point(115, 317)
	$labelPreislisten.Name = 'labelPreislisten'  
	$labelPreislisten.Size = New-Object System.Drawing.Size(65, 13)
	$labelPreislisten.TabIndex = 33
	$labelPreislisten.Text = 'Preislisten'  
	#
	# panel2
	#
	$panel2.Controls.Add($radiobuttonSNetto)
	$panel2.Controls.Add($radiobuttonNetto)
	$panel2.Controls.Add($radiobuttonBrutto)
	$panel2.Controls.Add($Ohne)
	$panel2.Location = New-Object System.Drawing.Point(115, 346)
	$panel2.Name = 'panel2'  
	$panel2.Size = New-Object System.Drawing.Size(331, 61)
	$panel2.TabIndex = 32
	#
	# radiobuttonSNetto
	#
	$radiobuttonSNetto.Location = New-Object System.Drawing.Point(224, 15)
	$radiobuttonSNetto.Name = 'radiobuttonSNetto'  
	$radiobuttonSNetto.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonSNetto.TabIndex = 3
	$radiobuttonSNetto.TabStop = $True
	$radiobuttonSNetto.Text = 'S Netto'  
	$radiobuttonSNetto.UseVisualStyleBackColor = $True
	$radiobuttonSNetto.add_CheckedChanged($radiobuttonSNetto_CheckedChanged)
	#
	# radiobuttonNetto
	#
	$radiobuttonNetto.Location = New-Object System.Drawing.Point(145, 15)
	$radiobuttonNetto.Name = 'radiobuttonNetto'  
	$radiobuttonNetto.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonNetto.TabIndex = 2
	$radiobuttonNetto.TabStop = $True
	$radiobuttonNetto.Text = 'Netto'  
	$radiobuttonNetto.UseVisualStyleBackColor = $True
	$radiobuttonNetto.add_CheckedChanged($radiobuttonNetto_CheckedChanged)
	#
	# radiobuttonBrutto
	#
	$radiobuttonBrutto.Location = New-Object System.Drawing.Point(76, 15)
	$radiobuttonBrutto.Name = 'radiobuttonBrutto'  
	$radiobuttonBrutto.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonBrutto.TabIndex = 1
	$radiobuttonBrutto.TabStop = $True
	$radiobuttonBrutto.Text = 'Brutto'  
	$radiobuttonBrutto.UseVisualStyleBackColor = $True
	$radiobuttonBrutto.add_CheckedChanged($radiobuttonBrutto_CheckedChanged)
	#
	# Ohne
	#
	$Ohne.Location = New-Object System.Drawing.Point(14, 15)
	$Ohne.Name = 'Ohne'  
	$Ohne.Size = New-Object System.Drawing.Size(104, 24)
	$Ohne.TabIndex = 0
	$Ohne.TabStop = $True
	$Ohne.Text = 'Ohne'  
	$Ohne.UseVisualStyleBackColor = $True
	$Ohne.add_CheckedChanged($Ohne_CheckedChanged)
	#
	# panel1
	#
	$panel1.Controls.Add($radiobuttonAndreeSchmidt)
	$panel1.Controls.Add($radiobuttonGasper)
	$panel1.Controls.Add($radiobuttonDirkWidmer)
	$panel1.Controls.Add($radiobuttonRobertBubendorfer)
	$panel1.Controls.Add($radiobuttonStefanReder)
	$panel1.Controls.Add($radiobuttonJörgBehr)
	$panel1.Controls.Add($radiobuttonMarkusScheuerer)
	$panel1.Controls.Add($radiobuttonAlexandraWust)
	$panel1.Controls.Add($radiobuttonRogerGustafsson)
	$panel1.Controls.Add($radiobuttonAchimSeybicke)
	$panel1.Controls.Add($radiobuttonMoritzVonCube)
	$panel1.Location = New-Object System.Drawing.Point(115, 158)
	$panel1.Name = 'panel1'  
	$panel1.Size = New-Object System.Drawing.Size(421, 127)
	$panel1.TabIndex = 31
	$panel1.add_Paint($panel1_Paint)
	#
	# radiobuttonAndreeSchmidt
	#
	$radiobuttonAndreeSchmidt.Location = New-Object System.Drawing.Point(3, 3)
	$radiobuttonAndreeSchmidt.Name = 'radiobuttonAndreeSchmidt'  
	$radiobuttonAndreeSchmidt.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonAndreeSchmidt.TabIndex = 11
	$radiobuttonAndreeSchmidt.TabStop = $True
	$radiobuttonAndreeSchmidt.Text = 'Andree Schmidt'  
	$radiobuttonAndreeSchmidt.UseVisualStyleBackColor = $True
	$radiobuttonAndreeSchmidt.add_CheckedChanged($radiobuttonAndreeSchmidt_CheckedChanged)
	#
	# radiobuttonGasper
	#
	$radiobuttonGasper.Location = New-Object System.Drawing.Point(239, 63)
	$radiobuttonGasper.Name = 'radiobuttonGasper'  
	$radiobuttonGasper.Size = New-Object System.Drawing.Size(131, 24)
	$radiobuttonGasper.TabIndex = 23
	$radiobuttonGasper.TabStop = $True
	$radiobuttonGasper.Text = 'Gasper'  
	$radiobuttonGasper.UseVisualStyleBackColor = $True
	$radiobuttonGasper.add_CheckedChanged($radiobuttonGasper_CheckedChanged)
	#
	# radiobuttonDirkWidmer
	#
	$radiobuttonDirkWidmer.Location = New-Object System.Drawing.Point(3, 33)
	$radiobuttonDirkWidmer.Name = 'radiobuttonDirkWidmer'  
	$radiobuttonDirkWidmer.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonDirkWidmer.TabIndex = 13
	$radiobuttonDirkWidmer.TabStop = $True
	$radiobuttonDirkWidmer.Text = 'Dirk Widmer'  
	$radiobuttonDirkWidmer.UseVisualStyleBackColor = $True
	$radiobuttonDirkWidmer.add_CheckedChanged($radiobuttonDirkWidmer_CheckedChanged)
	#
	# radiobuttonRobertBubendorfer
	#
	$radiobuttonRobertBubendorfer.Location = New-Object System.Drawing.Point(239, 33)
	$radiobuttonRobertBubendorfer.Name = 'radiobuttonRobertBubendorfer'  
	$radiobuttonRobertBubendorfer.Size = New-Object System.Drawing.Size(131, 24)
	$radiobuttonRobertBubendorfer.TabIndex = 15
	$radiobuttonRobertBubendorfer.TabStop = $True
	$radiobuttonRobertBubendorfer.Text = 'Robert Bubendorfer'  
	$radiobuttonRobertBubendorfer.UseVisualStyleBackColor = $True
	$radiobuttonRobertBubendorfer.add_CheckedChanged($radiobuttonRobertBubendorfer_CheckedChanged)
	#
	# radiobuttonStefanReder
	#
	$radiobuttonStefanReder.Location = New-Object System.Drawing.Point(239, 3)
	$radiobuttonStefanReder.Name = 'radiobuttonStefanReder'  
	$radiobuttonStefanReder.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonStefanReder.TabIndex = 22
	$radiobuttonStefanReder.TabStop = $True
	$radiobuttonStefanReder.Text = 'Stefan Reder'  
	$radiobuttonStefanReder.UseVisualStyleBackColor = $True
	$radiobuttonStefanReder.add_CheckedChanged($radiobuttonStefanReder_CheckedChanged)
	#
	# radiobuttonJörgBehr
	#
	$radiobuttonJörgBehr.Location = New-Object System.Drawing.Point(3, 63)
	$radiobuttonJörgBehr.Name = 'radiobuttonJörgBehr'  
	$radiobuttonJörgBehr.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonJörgBehr.TabIndex = 20
	$radiobuttonJörgBehr.TabStop = $True
	$radiobuttonJörgBehr.Text = 'Jörg Behr'  
	$radiobuttonJörgBehr.UseVisualStyleBackColor = $True
	$radiobuttonJörgBehr.add_CheckedChanged($radiobuttonJörgBehr_CheckedChanged)
	#
	# radiobuttonMarkusScheuerer
	#
	$radiobuttonMarkusScheuerer.Location = New-Object System.Drawing.Point(118, 93)
	$radiobuttonMarkusScheuerer.Name = 'radiobuttonMarkusScheuerer'  
	$radiobuttonMarkusScheuerer.Size = New-Object System.Drawing.Size(131, 24)
	$radiobuttonMarkusScheuerer.TabIndex = 17
	$radiobuttonMarkusScheuerer.TabStop = $True
	$radiobuttonMarkusScheuerer.Text = 'Markus Scheuerer'  
	$radiobuttonMarkusScheuerer.UseVisualStyleBackColor = $True
	$radiobuttonMarkusScheuerer.add_CheckedChanged($radiobuttonMarkusScheuerer_CheckedChanged)
	#
	# radiobuttonAlexandraWust
	#
	$radiobuttonAlexandraWust.Location = New-Object System.Drawing.Point(118, 30)
	$radiobuttonAlexandraWust.Name = 'radiobuttonAlexandraWust'  
	$radiobuttonAlexandraWust.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonAlexandraWust.TabIndex = 21
	$radiobuttonAlexandraWust.TabStop = $True
	$radiobuttonAlexandraWust.Text = 'Alexandra Wust'  
	$radiobuttonAlexandraWust.UseVisualStyleBackColor = $True
	$radiobuttonAlexandraWust.add_CheckedChanged($radiobuttonAlexandraWust_CheckedChanged)
	#
	# radiobuttonRogerGustafsson
	#
	$radiobuttonRogerGustafsson.Location = New-Object System.Drawing.Point(3, 93)
	$radiobuttonRogerGustafsson.Name = 'radiobuttonRogerGustafsson'  
	$radiobuttonRogerGustafsson.Size = New-Object System.Drawing.Size(112, 24)
	$radiobuttonRogerGustafsson.TabIndex = 18
	$radiobuttonRogerGustafsson.TabStop = $True
	$radiobuttonRogerGustafsson.Text = 'Roger Gustafsson'  
	$radiobuttonRogerGustafsson.UseVisualStyleBackColor = $True
	$radiobuttonRogerGustafsson.add_CheckedChanged($radiobuttonRogerGustafsson_CheckedChanged)
	#
	# radiobuttonAchimSeybicke
	#
	$radiobuttonAchimSeybicke.Location = New-Object System.Drawing.Point(118, 63)
	$radiobuttonAchimSeybicke.Name = 'radiobuttonAchimSeybicke'  
	$radiobuttonAchimSeybicke.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonAchimSeybicke.TabIndex = 19
	$radiobuttonAchimSeybicke.TabStop = $True
	$radiobuttonAchimSeybicke.Text = 'Achim Seybicke'  
	$radiobuttonAchimSeybicke.UseVisualStyleBackColor = $True
	$radiobuttonAchimSeybicke.add_CheckedChanged($radiobuttonAchimSeybicke_CheckedChanged)
	#
	# radiobuttonMoritzVonCube
	#
	$radiobuttonMoritzVonCube.Location = New-Object System.Drawing.Point(118, 0)
	$radiobuttonMoritzVonCube.Name = 'radiobuttonMoritzVonCube'  
	$radiobuttonMoritzVonCube.Size = New-Object System.Drawing.Size(104, 24)
	$radiobuttonMoritzVonCube.TabIndex = 12
	$radiobuttonMoritzVonCube.TabStop = $True
	$radiobuttonMoritzVonCube.Text = 'Moritz von Cube'  
	$radiobuttonMoritzVonCube.UseVisualStyleBackColor = $True
	$radiobuttonMoritzVonCube.add_CheckedChanged($radiobuttonMoritzVonCube_CheckedChanged)
	$panel1.ResumeLayout()
	$panel2.ResumeLayout()
	$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
Show-Katalog_Versand_Neu_psf | Out-Null

Content-ID: 3533131370

Url: https://administrator.de/contentid/3533131370

Ausgedruckt am: 21.11.2024 um 19:11 Uhr

colinardo
Lösung colinardo 03.08.2022 aktualisiert um 14:19:52 Uhr
Goto Top
Servus.
Ich ralle es aber absolut nicht wie ich die Anspreche um den richtigen "Check" zu erhalten.
As simple as
($panel1.Controls | ? Checked).Text
Grüße Uwe
Springstil
Springstil 03.08.2022 um 14:31:26 Uhr
Goto Top
manchmal .... :D Danke!!