locked
ShowDialog in vb.net 4.0 visual studio 2010 RRS feed

  • Question

  • Microsoft seem to have broken something that worked fine in 3.5 ShowDialog


    two forms very basic wnat 1 form to appear over anther

    the first form
    Public Class frmStart
    
        Private Sub btnLogView_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogView.Click
            ShowDialog(frmLogViewer)
        End Sub
    End Class
    the 2nd form
    Public Class frmLogViewer
    
        Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
            Me.Close()
        End Sub
    End Class
    The Error
    Form that is already visible cannot be displayed as a modal dialog box. Set the form's visible property to false before calling showDialog.
    help even better i would like the first form to close when the 2nd opens and then reapear when the 2nd form closes

    Thanks From Joe
    Thursday, December 24, 2009 4:19 PM

Answers

  • I disagree, When you call ShowDialog in Startform, you are asking to display very same form(startform) making your frmlogviewer to be a parent of startform.

    If you want to close the startform and open another form then you could go to Project Properties, Application Tab and change ShutDown behavior  to 'When Last form Closes'

    And Simply change btnLogView click handlers to
    LogViewer.Show()
    Close()
    Or Hide the first form and show the second one, and in second form's closing event you can display the first form



    Arjun Paudel
    Sunday, February 14, 2010 3:27 AM