PS Gui, Tabcontrol how to confirm if tab is selected

This topic contains 1 reply, has 1 voice, and was last updated by  Snak3d0c 2 years, 7 months ago.

  • Author
  • #32719


    So i'm creating my first tool. It has 3 tabpages , each with its own tasks.
    Now, when the app gets loaded, all functions are loaded at once. (and so all tabs are loaded at once)
    It would like to make it so that all functions get loaded when the tab if selected or clicked on.

    so i have

    #Tab Control 
    $tabControl.DataBindings.DefaultDataSourceUpdateMode = 0
    $System_Drawing_Point = New-Object System.Drawing.Point
    $System_Drawing_Point.X = 75
    $System_Drawing_Point.Y = 85
    $tabControl.Location = $System_Drawing_Point
    $tabControl.Name = "tabControl"
    $System_Drawing_Size = New-Object System.Drawing.Size
    $System_Drawing_Size.Height = 300
    $System_Drawing_Size.Width = 575
    $tabControl.Size = $System_Drawing_Size

    and e.g.

    #SQLHealth Page
    $SQLHealthPage.DataBindings.DefaultDataSourceUpdateMode = 0
    $SQLHealthPage.UseVisualStyleBackColor = $True
    $SQLHealthPage.Name = "SQLHealthPage"
    $SQLHealthPage.Text = "SQL Health Check"
    #CPU Page
    $CPUPage.DataBindings.DefaultDataSourceUpdateMode = 0
    $CPUPage.UseVisualStyleBackColor = $True
    $CPUPage.Name = "CPU"
    $CPUPage.Text = "CPU"

    i tried the following but that doesn't work.

    if ($TabControl.SelectedTab = $CPUPage)
    	Write-Host "hello tab cpuPage"
  • #32721


    So i figured it out, what you need to do is create a handler and then add it to the object. so
    first you do :

    $handler_tabpage_SelectedIndexChanged = {
    	Write-Host $tabControl.SelectedTab.Name
    	Write-Host "you changed tabs"

    and later on you add:


You must be logged in to reply to this topic.