none
ListBox -> SelectedItemIndex RRS feed

  • Frage

  • Hallo liebe Com :)

    Ich habe eine Frage bezüglich eines simplen Scriptes. 

     #Generated Form Function
    function GenerateForm {
    ########################################################################
    # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
    # Generated On: 22.12.2016 13:47
    # Generated By: Caner
    ########################################################################
    
    #region Import the Assemblies
    [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
    [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
    #endregion
    
    #region Generated Form Objects
    $Auswahl = New-Object System.Windows.Forms.Form
    $187 = New-Object System.Windows.Forms.Button
    $label2 = New-Object System.Windows.Forms.Label
    $Own8 = New-Object System.Windows.Forms.Button
    $Own7 = New-Object System.Windows.Forms.Button
    $Own6 = New-Object System.Windows.Forms.Button
    $button13 = New-Object System.Windows.Forms.Button
    $Own4 = New-Object System.Windows.Forms.Button
    $Own3 = New-Object System.Windows.Forms.Button
    $Own2 = New-Object System.Windows.Forms.Button
    $Own1 = New-Object System.Windows.Forms.Button
    $Philip_Morris = New-Object System.Windows.Forms.Button
    $Davidoff = New-Object System.Windows.Forms.Button
    $Parisienne = New-Object System.Windows.Forms.Button
    $LuckyStrike = New-Object System.Windows.Forms.Button
    $Camel = New-Object System.Windows.Forms.Button
    $Kent = New-Object System.Windows.Forms.Button
    $Winston = New-Object System.Windows.Forms.Button
    $Marlboro = New-Object System.Windows.Forms.Button
    $Auswahltext = New-Object System.Windows.Forms.Label
    $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
    #endregion Generated Form Objects
    
    #----------------------------------------------
    #Generated Event Script Blocks
    #----------------------------------------------
    #Provide Custom Code for events specified in PrimalForms.
    $Own4_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Parisienne_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Marlboro_OnClick= 
    {
        #Generated Form Function
        function GenerateForm {
        ########################################################################
        # Code Generated By: SAPIEN Technologies PrimalForms (Community Edition) v1.0.10.0
        # Generated On: 22.12.2016 13:49
        # Generated By: Caner
        ########################################################################
    
        #region Import the Assemblies
        [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
        [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
        #endregion
    
        #region Generated Form Objects
        $Auswahl = New-Object System.Windows.Forms.Form
        $Kohlenstoffmonoxid_wert = New-Object System.Windows.Forms.Label
        $Kohlenstoffmonoxid_text = New-Object System.Windows.Forms.Label
        $Nikotin_Wert = New-Object System.Windows.Forms.Label
        $Teer_wert = New-Object System.Windows.Forms.Label
        $Nikotin_text = New-Object System.Windows.Forms.Label
        $Teer_text = New-Object System.Windows.Forms.Label
        $listBox1 = New-Object System.Windows.Forms.ListBox
        $Auswahl_Text = New-Object System.Windows.Forms.Label
        $Markenname_Marlboro = New-Object System.Windows.Forms.Label
        $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
        #endregion Generated Form Objects
    
        #----------------------------------------------
        #Generated Event Script Blocks
        #----------------------------------------------
        #Provide Custom Code for events specified in PrimalForms.
        $handler_label1_Click= 
        {
        #TODO: Place custom script here
    
        }
    
        $OnLoadForm_StateCorrection=
        {#Correct the initial state of the form to prevent the .Net maximized form issue
    	    $Auswahl.WindowState = $InitialFormWindowState
        }
    
        #----------------------------------------------
        #region Generated Form Code
        $Auswahl.BackgroundImage = [System.Drawing.Image]::FromFile('C:\Users\Caner\Desktop\Desktop\TBZ\Modul 122\LB2\background.jpg')
        $Auswahl.BackgroundImageLayout = 3
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 421
        $System_Drawing_Size.Width = 305
        $Auswahl.ClientSize = $System_Drawing_Size
        $Auswahl.Cursor = [System.Windows.Forms.Cursors]::Arrow
        $Auswahl.DataBindings.DefaultDataSourceUpdateMode = 0
        $Auswahl.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon('C:\Users\Caner\Desktop\Desktop\TBZ\Modul 122\LB2\icon.ico')
        $Auswahl.Name = "Auswahl"
        $Auswahl.Text = "Zigi-Rechner"
    
        $Kohlenstoffmonoxid_wert.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Kohlenstoffmonoxid_wert.DataBindings.DefaultDataSourceUpdateMode = 0
        $Kohlenstoffmonoxid_wert.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 167
        $System_Drawing_Point.Y = 196
        $Kohlenstoffmonoxid_wert.Location = $System_Drawing_Point
        $Kohlenstoffmonoxid_wert.Name = "Kohlenstoffmonoxid_wert"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 100
        $Kohlenstoffmonoxid_wert.Size = $System_Drawing_Size
        $Kohlenstoffmonoxid_wert.TabIndex = 8
        $Kohlenstoffmonoxid_wert.Text = "X"
    
        $Auswahl.Controls.Add($Kohlenstoffmonoxid_wert)
    
        $Kohlenstoffmonoxid_text.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Kohlenstoffmonoxid_text.DataBindings.DefaultDataSourceUpdateMode = 0
        $Kohlenstoffmonoxid_text.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 13
        $System_Drawing_Point.Y = 197
        $Kohlenstoffmonoxid_text.Location = $System_Drawing_Point
        $Kohlenstoffmonoxid_text.Name = "Kohlenstoffmonoxid_text"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 116
        $Kohlenstoffmonoxid_text.Size = $System_Drawing_Size
        $Kohlenstoffmonoxid_text.TabIndex = 7
        $Kohlenstoffmonoxid_text.Text = "Kohlenstoffmonoxid:"
    
        $Auswahl.Controls.Add($Kohlenstoffmonoxid_text)
    
        $Nikotin_Wert.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Nikotin_Wert.DataBindings.DefaultDataSourceUpdateMode = 0
        $Nikotin_Wert.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 167
        $System_Drawing_Point.Y = 170
        $Nikotin_Wert.Location = $System_Drawing_Point
        $Nikotin_Wert.Name = "Nikotin_Wert"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 100
        $Nikotin_Wert.Size = $System_Drawing_Size
        $Nikotin_Wert.TabIndex = 6
        $Nikotin_Wert.Text = "X"
    
        $Auswahl.Controls.Add($Nikotin_Wert)
    
        $Teer_wert.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Teer_wert.DataBindings.DefaultDataSourceUpdateMode = 0
        $Teer_wert.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 167
        $System_Drawing_Point.Y = 143
        $Teer_wert.Location = $System_Drawing_Point
        $Teer_wert.Name = "Teer_wert"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 100
        $Teer_wert.Size = $System_Drawing_Size
        $Teer_wert.TabIndex = 5
        $Teer_wert.Text = "X"
    
        $Auswahl.Controls.Add($Teer_wert)
    
        $Nikotin_text.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Nikotin_text.DataBindings.DefaultDataSourceUpdateMode = 0
        $Nikotin_text.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 13
        $System_Drawing_Point.Y = 170
        $Nikotin_text.Location = $System_Drawing_Point
        $Nikotin_text.Name = "Nikotin_text"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 100
        $Nikotin_text.Size = $System_Drawing_Size
        $Nikotin_text.TabIndex = 4
        $Nikotin_text.Text = "Nikotin:"
    
        $Auswahl.Controls.Add($Nikotin_text)
    
        $Teer_text.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Teer_text.DataBindings.DefaultDataSourceUpdateMode = 0
        $Teer_text.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 13
        $System_Drawing_Point.Y = 143
        $Teer_text.Location = $System_Drawing_Point
        $Teer_text.Name = "Teer_text"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 37
        $Teer_text.Size = $System_Drawing_Size
        $Teer_text.TabIndex = 3
        $Teer_text.Text = "Teer:"
    
        $Auswahl.Controls.Add($Teer_text)
    
        $listBox1.DataBindings.DefaultDataSourceUpdateMode = 0
        $listBox1.FormattingEnabled = $True
        $listBox1.Items.Add("Marlboro Rot")|Out-Null
        $listBox1.Items.Add("Marlboro Gold")|Out-Null
        $listBox1.Items.Add("Marlboro Silver")|Out-Null
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 167
        $System_Drawing_Point.Y = 47
        $listBox1.Location = $System_Drawing_Point
        $listBox1.Name = "listBox1"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 43
        $System_Drawing_Size.Width = 120
        $listBox1.Size = $System_Drawing_Size
        $listBox1.TabIndex = 2
    
        $Auswahl.Controls.Add($listBox1)
    
        $Auswahl_Text.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Auswahl_Text.Cursor = [System.Windows.Forms.Cursors]::Arrow
        $Auswahl_Text.DataBindings.DefaultDataSourceUpdateMode = 0
        $Auswahl_Text.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 13
        $System_Drawing_Point.Y = 47
        $Auswahl_Text.Location = $System_Drawing_Point
        $Auswahl_Text.Name = "Auswahl_Text"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 137
        $Auswahl_Text.Size = $System_Drawing_Size
        $Auswahl_Text.TabIndex = 1
        $Auswahl_Text.Text = "Wählen Sie die Sorte aus:"
    
        $Auswahl.Controls.Add($Auswahl_Text)
    
        $Markenname_Marlboro.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
        $Markenname_Marlboro.DataBindings.DefaultDataSourceUpdateMode = 0
        $Markenname_Marlboro.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
        $System_Drawing_Point = New-Object System.Drawing.Point
        $System_Drawing_Point.X = 12
        $System_Drawing_Point.Y = 20
        $Markenname_Marlboro.Location = $System_Drawing_Point
        $Markenname_Marlboro.Name = "Markenname_Marlboro"
        $System_Drawing_Size = New-Object System.Drawing.Size
        $System_Drawing_Size.Height = 23
        $System_Drawing_Size.Width = 204
        $Markenname_Marlboro.Size = $System_Drawing_Size
        $Markenname_Marlboro.TabIndex = 0
        $Markenname_Marlboro.Text = "Marlboro"
        $Markenname_Marlboro.add_Click($handler_label1_Click)
    
    
            $listBox1_selectedindexchanged= {
            write-host $listBox1.SelectedItem
            if($listBox1_selectedindexchanged = 1){
            $Teer_wert = "abc"
            }
        }
        
    
    
        $listBox1.add_selectedindexchanged($listBox1_selectedindexchanged)
    
    
    
    
        $Auswahl.Controls.Add($Markenname_Marlboro)
    
        #endregion Generated Form Code
    
        #Save the initial state of the form
        $InitialFormWindowState = $Auswahl.WindowState
        #Init the OnLoad event to correct the initial state of the form
        $Auswahl.add_Load($OnLoadForm_StateCorrection)
        #Show the Form
        $Auswahl.ShowDialog()| Out-Null
    
        
        
    
        } #End Function
    
        #Call the Function
        GenerateForm
    
    }
    
    $Own7_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Own2_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $187_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $handler_label2_Click= 
    {
    #TODO: Place custom script here
    
    }
    
    $Winston_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $button13_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Own6_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Own8_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Camel_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Own1_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Kent_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $handler_label1_Click= 
    {
    #TODO: Place custom script here
    
    }
    
    $LuckyStrike_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Own3_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Philip_Morris_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $Davidoff_OnClick= 
    {
    #TODO: Place custom script here
    
    }
    
    $OnLoadForm_StateCorrection=
    {#Correct the initial state of the form to prevent the .Net maximized form issue
    	$Auswahl.WindowState = $InitialFormWindowState
    }
    
    #----------------------------------------------
    #region Generated Form Code
    $Auswahl.BackgroundImage = [System.Drawing.Image]::FromFile('C:\Users\Caner\Desktop\Desktop\TBZ\Modul 122\LB2\background.jpg')
    $Auswahl.BackgroundImageLayout = 3
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 421
    $System_Drawing_Size.Width = 584
    $Auswahl.ClientSize = $System_Drawing_Size
    $Auswahl.Cursor = [System.Windows.Forms.Cursors]::Arrow
    $Auswahl.DataBindings.DefaultDataSourceUpdateMode = 0
    $Auswahl.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon('C:\Users\Caner\Desktop\Desktop\TBZ\Modul 122\LB2\icon.ico')
    $Auswahl.Name = "Auswahl"
    $Auswahl.Text = "Zigi-Rechner"
    
    
    $187.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 546
    $System_Drawing_Point.Y = 397
    $187.Location = $System_Drawing_Point
    $187.Name = "187"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 24
    $System_Drawing_Size.Width = 35
    $187.Size = $System_Drawing_Size
    $187.TabIndex = 18
    $187.Text = "187"
    $187.UseVisualStyleBackColor = $True
    $187.add_Click($187_OnClick)
    
    $Auswahl.Controls.Add($187)
    
    $label2.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
    $label2.DataBindings.DefaultDataSourceUpdateMode = 0
    $label2.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 175
    $System_Drawing_Point.Y = 234
    $label2.Location = $System_Drawing_Point
    $label2.Name = "label2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 204
    $label2.Size = $System_Drawing_Size
    $label2.TabIndex = 17
    $label2.Text = "Ist deine Zigarettenmarke nicht dabei?"
    $label2.add_Click($handler_label2_Click)
    
    $Auswahl.Controls.Add($label2)
    
    
    $Own8.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 464
    $System_Drawing_Point.Y = 335
    $Own8.Location = $System_Drawing_Point
    $Own8.Name = "Own8"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own8.Size = $System_Drawing_Size
    $Own8.TabIndex = 16
    $Own8.Text = "Own8"
    $Own8.UseVisualStyleBackColor = $True
    $Own8.add_Click($Own8_OnClick)
    
    $Auswahl.Controls.Add($Own8)
    
    
    $Own7.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 306
    $System_Drawing_Point.Y = 335
    $Own7.Location = $System_Drawing_Point
    $Own7.Name = "Own7"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own7.Size = $System_Drawing_Size
    $Own7.TabIndex = 15
    $Own7.Text = "Own7"
    $Own7.UseVisualStyleBackColor = $True
    $Own7.add_Click($Own7_OnClick)
    
    $Auswahl.Controls.Add($Own7)
    
    
    $Own6.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 175
    $System_Drawing_Point.Y = 335
    $Own6.Location = $System_Drawing_Point
    $Own6.Name = "Own6"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own6.Size = $System_Drawing_Size
    $Own6.TabIndex = 14
    $Own6.Text = "Own6"
    $Own6.UseVisualStyleBackColor = $True
    $Own6.add_Click($Own6_OnClick)
    
    $Auswahl.Controls.Add($Own6)
    
    
    $button13.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 25
    $System_Drawing_Point.Y = 335
    $button13.Location = $System_Drawing_Point
    $button13.Name = "button13"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $button13.Size = $System_Drawing_Size
    $button13.TabIndex = 13
    $button13.Text = "Own5"
    $button13.UseVisualStyleBackColor = $True
    $button13.add_Click($button13_OnClick)
    
    $Auswahl.Controls.Add($button13)
    
    
    $Own4.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 464
    $System_Drawing_Point.Y = 276
    $Own4.Location = $System_Drawing_Point
    $Own4.Name = "Own4"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own4.Size = $System_Drawing_Size
    $Own4.TabIndex = 12
    $Own4.Text = "Own4"
    $Own4.UseVisualStyleBackColor = $True
    $Own4.add_Click($Own4_OnClick)
    
    $Auswahl.Controls.Add($Own4)
    
    
    $Own3.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 304
    $System_Drawing_Point.Y = 276
    $Own3.Location = $System_Drawing_Point
    $Own3.Name = "Own3"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own3.Size = $System_Drawing_Size
    $Own3.TabIndex = 11
    $Own3.Text = "Own3"
    $Own3.UseVisualStyleBackColor = $True
    $Own3.add_Click($Own3_OnClick)
    
    $Auswahl.Controls.Add($Own3)
    
    
    $Own2.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 175
    $System_Drawing_Point.Y = 276
    $Own2.Location = $System_Drawing_Point
    $Own2.Name = "Own2"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own2.Size = $System_Drawing_Size
    $Own2.TabIndex = 10
    $Own2.Text = "Own2"
    $Own2.UseVisualStyleBackColor = $True
    $Own2.add_Click($Own2_OnClick)
    
    $Auswahl.Controls.Add($Own2)
    
    
    $Own1.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 25
    $System_Drawing_Point.Y = 276
    $Own1.Location = $System_Drawing_Point
    $Own1.Name = "Own1"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Own1.Size = $System_Drawing_Size
    $Own1.TabIndex = 9
    $Own1.Text = "Own1"
    $Own1.UseVisualStyleBackColor = $True
    $Own1.add_Click($Own1_OnClick)
    
    $Auswahl.Controls.Add($Own1)
    
    
    $Philip_Morris.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 464
    $System_Drawing_Point.Y = 158
    $Philip_Morris.Location = $System_Drawing_Point
    $Philip_Morris.Name = "Philip_Morris"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Philip_Morris.Size = $System_Drawing_Size
    $Philip_Morris.TabIndex = 8
    $Philip_Morris.Text = "Philip Morris"
    $Philip_Morris.UseVisualStyleBackColor = $True
    $Philip_Morris.add_Click($Philip_Morris_OnClick)
    
    $Auswahl.Controls.Add($Philip_Morris)
    
    
    $Davidoff.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 306
    $System_Drawing_Point.Y = 158
    $Davidoff.Location = $System_Drawing_Point
    $Davidoff.Name = "Davidoff"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Davidoff.Size = $System_Drawing_Size
    $Davidoff.TabIndex = 7
    $Davidoff.Text = "Davidoff"
    $Davidoff.UseVisualStyleBackColor = $True
    $Davidoff.add_Click($Davidoff_OnClick)
    
    $Auswahl.Controls.Add($Davidoff)
    
    
    $Parisienne.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 175
    $System_Drawing_Point.Y = 158
    $Parisienne.Location = $System_Drawing_Point
    $Parisienne.Name = "Parisienne"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Parisienne.Size = $System_Drawing_Size
    $Parisienne.TabIndex = 6
    $Parisienne.Text = "Parisienne"
    $Parisienne.UseVisualStyleBackColor = $True
    $Parisienne.add_Click($Parisienne_OnClick)
    
    $Auswahl.Controls.Add($Parisienne)
    
    
    $LuckyStrike.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 25
    $System_Drawing_Point.Y = 158
    $LuckyStrike.Location = $System_Drawing_Point
    $LuckyStrike.Name = "LuckyStrike"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $LuckyStrike.Size = $System_Drawing_Size
    $LuckyStrike.TabIndex = 5
    $LuckyStrike.Text = "LuckyStrike"
    $LuckyStrike.UseVisualStyleBackColor = $True
    $LuckyStrike.add_Click($LuckyStrike_OnClick)
    
    $Auswahl.Controls.Add($LuckyStrike)
    
    
    $Camel.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 464
    $System_Drawing_Point.Y = 72
    $Camel.Location = $System_Drawing_Point
    $Camel.Name = "Camel"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Camel.Size = $System_Drawing_Size
    $Camel.TabIndex = 4
    $Camel.Text = "Camel"
    $Camel.UseVisualStyleBackColor = $True
    $Camel.add_Click($Camel_OnClick)
    
    $Auswahl.Controls.Add($Camel)
    
    
    $Kent.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 306
    $System_Drawing_Point.Y = 72
    $Kent.Location = $System_Drawing_Point
    $Kent.Name = "Kent"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Kent.Size = $System_Drawing_Size
    $Kent.TabIndex = 3
    $Kent.Text = "Kent"
    $Kent.UseVisualStyleBackColor = $True
    $Kent.add_Click($Kent_OnClick)
    
    $Auswahl.Controls.Add($Kent)
    
    
    $Winston.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 175
    $System_Drawing_Point.Y = 72
    $Winston.Location = $System_Drawing_Point
    $Winston.Name = "Winston"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Winston.Size = $System_Drawing_Size
    $Winston.TabIndex = 2
    $Winston.Text = "Winston"
    $Winston.UseVisualStyleBackColor = $True
    $Winston.add_Click($Winston_OnClick)
    
    $Auswahl.Controls.Add($Winston)
    
    
    $Marlboro.DataBindings.DefaultDataSourceUpdateMode = 0
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 25
    $System_Drawing_Point.Y = 73
    $Marlboro.Location = $System_Drawing_Point
    $Marlboro.Name = "Marlboro"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 75
    $Marlboro.Size = $System_Drawing_Size
    $Marlboro.TabIndex = 1
    $Marlboro.Text = "Marlboro"
    $Marlboro.UseVisualStyleBackColor = $True
    $Marlboro.add_Click($Marlboro_OnClick)
    
    $Auswahl.Controls.Add($Marlboro)
    
    $Auswahltext.BackColor = [System.Drawing.Color]::FromArgb(0,255,255,255)
    $Auswahltext.DataBindings.DefaultDataSourceUpdateMode = 0
    $Auswahltext.ForeColor = [System.Drawing.Color]::FromArgb(255,255,255,255)
    
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 175
    $System_Drawing_Point.Y = 20
    $Auswahltext.Location = $System_Drawing_Point
    $Auswahltext.Name = "Auswahltext"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 23
    $System_Drawing_Size.Width = 204
    $Auswahltext.Size = $System_Drawing_Size
    $Auswahltext.TabIndex = 0
    $Auswahltext.Text = "Bitte wähle deine Zigarettenmarke aus:"
    $Auswahltext.add_Click($handler_label1_Click)
    
    $Auswahl.Controls.Add($Auswahltext)
    
    #endregion Generated Form Code
    
    #Save the initial state of the form
    $InitialFormWindowState = $Auswahl.WindowState
    #Init the OnLoad event to correct the initial state of the form
    $Auswahl.add_Load($OnLoadForm_StateCorrection)
    #Show the Form
    $Auswahl.ShowDialog()| Out-Null
    
    } #End Function
    
    #Call the Function
    GenerateForm
    

    Wie krieg es hin, dass wenn bei der ListBox1 zb. Marlboro Rot ausgewählt ist, es die Variabel $Teer_Wert auf Xmg ändert?

            $listBox1_selectedindexchanged= {
            write-host $listBox1.SelectedItem
            if($listBox1_selectedindexchanged = asd){
            $Teer_wert = "abc"
            }
        }
        
    
    
        $listBox1.add_selectedindexchanged($listBox1_selectedindexchanged)


    Caner Savas

    Dienstag, 17. Januar 2017 08:22

Antworten