WinForm - Add_KeyDown in TabPage

Welcome Forums General PowerShell Q&A WinForm - Add_KeyDown in TabPage

This topic contains 3 replies, has 2 voices, and was last updated by

1 month ago.

  • Author
  • #177801

    Topics: 2
    Replies: 4
    Points: 37
    Rank: Member



    I created a GUI with Winform/Powershell.

    I have a tabcontrol with 3 tabpages

    I have an issue when I want to add a KeyDown event on a tabpage (Enter to perform a click).

    It works if I add the keydown event on my main form but not in a tabpage.

    Thank you in advance for your answer.


  • #177882

    Senior Moderator
    Topics: 8
    Replies: 1085
    Points: 3,651
    Helping Hand
    Rank: Community Hero

    is it possible to show us the code here. Showing us the code if possible will help us to understand the problem better.
    You can use to share the code and paste the url here.

  • #177984

    Topics: 2
    Replies: 4
    Points: 37
    Rank: Member

    Yes sure.

    You can find the test code that I made before implanting is my final project :

    $windows2 = New-object System.Windows.Forms.Form
        $windows2.size = New-object System.Drawing.size(1000,500)   
        $windows2.text = "Change Password"
    $tabcontrol_userInformation = New-object System.Windows.Forms.TabControl
        $tabcontrol_userInformation.Size = New-object System.Drawing.Size(965,440)
        $tabcontrol_userInformation.Location = New-object System.Drawing.Size(10,10)
        $tabcontrol_userInformation.Anchor = [System.Windows.Forms.AnchorStyles]::bottom -bor [System.Windows.Forms.AnchorStyles]::right -bor [System.Windows.Forms.AnchorStyles]::top -bor [System.Windows.Forms.AnchorStyles]::left
    $tabpage1 = New-object System.Windows.forms.TabPage
        $tabpage1.Text = "User Information"
    $tabpage2 = New-object System.Windows.forms.TabPage
        $tabpage2.Text = "Test"
    $buttonOK = New-object System.Windows.Forms.Button
        $buttonOK.Location = New-object System.Drawing.Size(80,150)
        $buttonOK.size = New-object System.Drawing.Size(80,30)
            if($_.KeyCode -eq 'Enter')
        $buttonOK.Text = "Ok"
    [void] $windows2.ShowDialog()

    Thank you for your help.

  • #178230

    Topics: 2
    Replies: 4
    Points: 37
    Rank: Member


    Someone can help me ?

    Thank you.

You must be logged in to reply to this topic.