如何强制表单在应用程序启动时再次显示?

时间:2016-10-06 12:50:25

标签: vb.net winforms

我有一个帮助表单,第一次显示应用程序启动时。初次启动后,该表单不再显示。有没有办法重置节目表格?这是我的代码,只根据应用程序设置显示一次。当应用程序退出时,应用程序将showform设置为false。 << - 需要在用户的计算机上重置。我需要的原因是,如果我有应用程序的更新,我需要向用户显示该帮助表单上的更新。

Private Sub AboutInformation_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
  If IsNewVersionAvailable() = True Then
    Dim showNextTime As Boolean
    showNextTime = My.Settings.LoadAboutForm
    If showNextTime = False Then
        Show()
        Location = New Point(0, 0)
        showNextTime = True
        My.Settings.LoadAboutForm = showNextTime
        My.Settings.Save()
    Else
        Close()
        myForm.Show()
    End If
End if
End Sub

1 个答案:

答案 0 :(得分:0)

对于寻找答案的任何人,我将当前版本保存在主窗体关闭的应用程序设置中,并在帮助表单启动时检查先前版本是否与更新版本匹配,如果不匹配则会显示帮助形式,如果它,它跳到主要的。

Private Sub AboutInformation_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
    Location = New Point(0, 0)
    'If ApplicationDeployment.IsNetworkDeployed Then
    Try
        Dim thisVersion As Version = ApplicationDeployment.CurrentDeployment.CurrentVersion
        If thisVersion.ToString = My.Settings.CurrentVersion Then
            Dim showNextTime As Boolean
            showNextTime = My.Settings.LoadAboutForm
            If showNextTime = False Then
                Show()
                Location = New Point(0, 0)
                showNextTime = True
                My.Settings.LoadAboutForm = showNextTime
                My.Settings.Save()
            Else
                Close()
                myMainForm.Show()
            End If
        End If
    Catch ex As Exception
        'MsgBox(ex.Message)
    End Try

End Sub


'Saving setting for main form closed.

Private Sub myMainForm_FormClosed(ByVal sender As Object, ByVal e As FormClosedEventArgs) Handles Me.FormClosed
    If ApplicationDeployment.IsNetworkDeployed Then
        Dim currentVersion As Version = ApplicationDeployment.CurrentDeployment.CurrentVersion
        Debug.Print(currentVersion.ToString)
        My.Settings.CurrentVersion = currentVersion.ToString
    End If
    My.Settings.Save()
End Sub
相关问题