第二次显示后未调用表格显示

时间:2019-06-30 03:07:40

标签: vb.net winforms

因此,我正在使用Visual Basic创建Windows窗体应用程序。我旁边有按钮来选择表格like this。当按下“预订”按钮时,用户将其带到外观为like this的表格。每次显示表单时我都需要运行以下代码(隐藏多次显示该表单)。我将以下代码放入表单加载和表单显示的动作中,并且它们都只会在第一次运行时运行。该代码不是真正相关的,我只需要知道如何在每次显示表单时(而不是一次)进行此运行。我想到的唯一可行的方法是使代码每秒运行一次,这是不必要的,而且浪费了处理能力。另外,如果我希望在此之后执行其他操作,则每秒发生的操作将具有优先权。

 Private Sub Form2_Shown(sender As Object, e As EventArgs) Handles Me.Shown
    If GlobalVariables.GlobalFlag = "1" Then
        Table1Sleep.Visible = False
        Table1Selected.Visible = True
        Table1Selected.BringToFront()
        table1text.BringToFront()
        table1textdesc.BringToFront()
    ElseIf GlobalVariables.GlobalFlag = "2" Then
        Table2Sleep.Visible = False
        Table2Selected.Visible = True
        Table2Selected.BringToFront()
        table2textdesc.BringToFront()
        table2text.BringToFront()

    ElseIf GlobalVariables.GlobalFlag = "3" Then
        Table3Sleep.Visible = False
        Table3Selected.Visible = True
        Table3Selected.BringToFront()
        table3text.BringToFront()
        table3textdesc.BringToFront()
    ElseIf GlobalVariables.GlobalFlag = "4" Then
        Table4Selected.Visible = True
        Table4Selected.BringToFront()
        tabel4text.BringToFront()
        table4textdesc.BringToFront()
        table4sleep.Visible = False
    ElseIf GlobalVariables.GlobalFlag = "5" Then
        Table5Selected.Visible = True
        table5sleep.Visible = False
        Table5Selected.BringToFront()
        table5text.BringToFront()
        table5textdesc.BringToFront()
    ElseIf GlobalVariables.GlobalFlag = "6" Then
        table6sleep.Visible = False
        Table6Selected.Visible = True
        Table6Selected.BringToFront()
        table6text.BringToFront()
        table6textdesc.BringToFront()
    Else
        MessageBox.Show("Something went wrong. When you press 'OK', you will be taken back to the Main Menu.")
        MainMenuForm.Show()
        Me.Close()
    End If
End Sub

谢谢:)

0 个答案:

没有答案