Cannot open the form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Vivek

    #1

    Cannot open the form

    Hi,

    I am using this code to open the form...
    ---------------------------------------------------------------------------------------
    Private frmAddUser as AddUser()
    Dim fc As Form
    For Each fc In Me.MdiParent.Md iChildren

    If fc Is frmAddUser Then

    If fc.WindowState = FormWindowState .Minimized Then

    fc.WindowState = FormWindowState .Normal

    End If

    fc.Show()

    fc.Focus()

    Return

    End If

    Next

    If (frmAddUser Is Nothing) Then

    frmAddUser = New AddUser

    frmAddUser.MdiP arent = Me.MdiParent

    frmAddUser.Show ()

    End If

    ---------------------------------------------------------------------

    When I close the form and try to reopen it does not open the form. It still recognises that frmAddUser exists. How do I kill the instance when I close the form?

    Thanks

    Vivek

  • Ken Tucker [MVP]

    #2
    Re: Cannot open the form

    Hi,

    If the form is already a mdichild try fc.bringtofront instead of
    fc.show to reshow the form

    http://msdn.microsoft.com/library/de...fronttopic.asp


    Ken
    --------------------
    "Vivek" <viveks@xtra.co .nz> wrote in message
    news:eLuusYhaFH A.1040@TK2MSFTN GP10.phx.gbl...
    Hi,

    I am using this code to open the form...
    ---------------------------------------------------------------------------------------
    Private frmAddUser as AddUser()
    Dim fc As Form
    For Each fc In Me.MdiParent.Md iChildren
    If fc Is frmAddUser Then
    If fc.WindowState = FormWindowState .Minimized Then
    fc.WindowState = FormWindowState .Normal
    End If
    fc.Show()
    fc.Focus()
    Return
    End If
    Next
    If (frmAddUser Is Nothing) Then
    frmAddUser = New AddUser
    frmAddUser.MdiP arent = Me.MdiParent
    frmAddUser.Show ()
    End If
    ---------------------------------------------------------------------
    When I close the form and try to reopen it does not open the form. It still
    recognises that frmAddUser exists. How do I kill the instance when I close
    the form?
    Thanks
    Vivek


    Comment

    • Vivek

      #3
      Re: Cannot open the form

      Sorry but it did not work for me

      "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
      news:OXZXEsiaFH A.584@TK2MSFTNG P15.phx.gbl...[color=blue]
      > Hi,
      >
      > If the form is already a mdichild try fc.bringtofront instead of
      > fc.show to reshow the form
      >
      > http://msdn.microsoft.com/library/de...fronttopic.asp
      >
      >
      > Ken
      > --------------------
      > "Vivek" <viveks@xtra.co .nz> wrote in message
      > news:eLuusYhaFH A.1040@TK2MSFTN GP10.phx.gbl...
      > Hi,
      >
      > I am using this code to open the form...
      > ---------------------------------------------------------------------------------------
      > Private frmAddUser as AddUser()
      > Dim fc As Form
      > For Each fc In Me.MdiParent.Md iChildren
      > If fc Is frmAddUser Then
      > If fc.WindowState = FormWindowState .Minimized Then
      > fc.WindowState = FormWindowState .Normal
      > End If
      > fc.Show()
      > fc.Focus()
      > Return
      > End If
      > Next
      > If (frmAddUser Is Nothing) Then
      > frmAddUser = New AddUser
      > frmAddUser.MdiP arent = Me.MdiParent
      > frmAddUser.Show ()
      > End If
      > ---------------------------------------------------------------------
      > When I close the form and try to reopen it does not open the form. It
      > still
      > recognises that frmAddUser exists. How do I kill the instance when I
      > close
      > the form?
      > Thanks
      > Vivek
      >
      >[/color]


      Comment

      • Peter Proost

        #4
        Re: Cannot open the form

        Hi, maybe this can help you, I hope the code is clear otherwise feel free to
        ask:

        Private Sub MenuItem2_Click (ByVal sender As System.Object, ByVal e As
        System.EventArg s) Handles _ MenuItem2.Click
        If checkFormOpen = False Then
        Dim obj As New Form2
        obj.MdiParent = Me
        obj.WindowState = FormWindowState .Maximized
        obj.Show()
        End If
        End Sub

        Private Function checkFormOpen() As Boolean
        Dim objForm As Form
        For Each objForm In Me.MdiChildren
        If TypeOf objForm Is Form2 Then
        objForm.WindowS tate = FormWindowState .Maximized
        objForm.BringTo Front()
        Return True
        End If
        Next
        Return False
        End Function
        --
        Programming today is a race between software engineers striving to build
        bigger and better idiot-proof programs, and the Universe trying to produce
        bigger and better idiots. So far, the Universe is winning.

        "Vivek" <viveks@xtra.co .nz> schreef in bericht
        news:uq$Yf8maFH A.1384@TK2MSFTN GP09.phx.gbl...[color=blue]
        > Sorry but it did not work for me
        >
        > "Ken Tucker [MVP]" <vb2ae@bellsout h.net> wrote in message
        > news:OXZXEsiaFH A.584@TK2MSFTNG P15.phx.gbl...[color=green]
        > > Hi,
        > >
        > > If the form is already a mdichild try fc.bringtofront instead of
        > > fc.show to reshow the form
        > >
        > >[/color][/color]
        http://msdn.microsoft.com/library/de...us/cpref/html/
        frlrfsystemwind owsformscontrol classbringtofro nttopic.asp[color=blue][color=green]
        > >
        > >
        > > Ken
        > > --------------------
        > > "Vivek" <viveks@xtra.co .nz> wrote in message
        > > news:eLuusYhaFH A.1040@TK2MSFTN GP10.phx.gbl...
        > > Hi,
        > >
        > > I am using this code to open the form...[/color]
        >
        > --------------------------------------------------------------------------[/color]
        -------------[color=blue][color=green]
        > > Private frmAddUser as AddUser()
        > > Dim fc As Form
        > > For Each fc In Me.MdiParent.Md iChildren
        > > If fc Is frmAddUser Then
        > > If fc.WindowState = FormWindowState .Minimized Then
        > > fc.WindowState = FormWindowState .Normal
        > > End If
        > > fc.Show()
        > > fc.Focus()
        > > Return
        > > End If
        > > Next
        > > If (frmAddUser Is Nothing) Then
        > > frmAddUser = New AddUser
        > > frmAddUser.MdiP arent = Me.MdiParent
        > > frmAddUser.Show ()
        > > End If
        > > ---------------------------------------------------------------------
        > > When I close the form and try to reopen it does not open the form. It
        > > still
        > > recognises that frmAddUser exists. How do I kill the instance when I
        > > close
        > > the form?
        > > Thanks
        > > Vivek
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Cor Ligthert

          #5
          Re: Cannot open the form

          Vivek,

          Will you please sent next time not in HTML format, and as well in a better
          readable way, with all those linespaces it is almost impossible to get a
          good idea what you are doing.

          Probably is the only thing you want to do something as
          \\\
          If frmAddUser.isdi sposed then
          frmAddUser is new AddUser
          End if
          frmAddUser.show
          ///
          I hope this helps,

          Cor



          Comment

          • Armin Zingler

            #6
            Re: Cannot open the form

            "Vivek" <viveks@xtra.co .nz> schrieb[color=blue]
            >
            > I am using this code to open the form...
            > -------------------------------------------------------------
            > -------------------------- Private frmAddUser as AddUser()
            > Dim fc As Form
            > For Each fc In Me.MdiParent.Md iChildren
            >
            > If fc Is frmAddUser Then
            >
            > If fc.WindowState = FormWindowState .Minimized Then
            >
            > fc.WindowState = FormWindowState .Normal
            >
            > End If
            >
            > fc.Show()
            >
            > fc.Focus()
            >
            > Return
            >
            > End If
            >
            > Next
            >
            > If (frmAddUser Is Nothing) Then
            >
            > frmAddUser = New AddUser
            >
            > frmAddUser.MdiP arent = Me.MdiParent
            >
            > frmAddUser.Show ()
            >
            > End If
            >
            > ---------------------------------------------------------------
            > ------
            >
            > When I close the form and try to reopen it does not open the form. It
            > still recognises that frmAddUser exists. How do I kill the instance
            > when I close the form?[/color]


            You can remove the reference (frmAdduser=not hing) by handling the Closed
            event of the form (declare frmadduser withevents or use addhandler to attach
            the event handler). BTW, within the first If..Endif block, try
            frmAdduser.Acti vate instead (and maybe .Show additionally because
            ..Activate is sometimes not enough).


            Ar min

            Comment

            • Vivek

              #7
              Re: Cannot open the form

              Thanks.

              I tried this but got an error
              Private Sub AddUserToolStri pMenuItem_Click _1(ByVal sender As
              System.Object, ByVal e As System.EventArg s) Handles
              AddUserToolStri pMenuItem.Click
              Dim fc As Form

              For Each fc In Me.MdiParent.Md iChildren
              If fc Is frmAddUser Then

              If fc.WindowState = FormWindowState .Minimized Then
              fc.WindowState = FormWindowState .Normal
              End If
              fc.Show()
              fc.Focus()
              Return
              End If
              Next

              If (frmAddUser.IsD isposed) Then
              frmAddUser = New AddUser
              frmAddUser.MdiP arent = Me.MdiParent
              End If

              frmAddUser.Show ()

              End Sub


              "Cor Ligthert" <notmyfirstname @planet.nl> wrote in message
              news:ewFc5NnaFH A.3048@TK2MSFTN GP12.phx.gbl...[color=blue]
              > Vivek,
              >
              > Will you please sent next time not in HTML format, and as well in a better
              > readable way, with all those linespaces it is almost impossible to get a
              > good idea what you are doing.
              >
              > Probably is the only thing you want to do something as
              > \\\
              > If frmAddUser.isdi sposed then
              > frmAddUser is new AddUser
              > End if
              > frmAddUser.show
              > ///
              > I hope this helps,
              >
              > Cor
              >
              >
              >[/color]


              Comment

              • Cor Ligthert

                #8
                Re: Cannot open the form

                Vivek,

                Tell next time what the error is, that makes it much easier to give an
                answer, now it still is a gues. See in line what is probably the solution to
                the error.

                (This is another approach and basicly the one I take, my sample I showed you
                was in the way Herfried does it, which is shorter however remove that again)
                [color=blue]
                > I tried this but got an error
                > Private Sub AddUserToolStri pMenuItem_Click _1(ByVal sender As
                > System.Object, ByVal e As System.EventArg s) Handles
                > AddUserToolStri pMenuItem.Click
                > Dim fc As Form
                >
                > For Each fc In Me.MdiParent.Md iChildren[/color]

                If fc.Name = "AddUser" Then

                Or 'that I never did

                If typeof fc Is AddUser Then
                [color=blue]
                >
                > If fc.WindowState = FormWindowState .Minimized Then
                > fc.WindowState = FormWindowState .Normal
                > End If
                > fc.Show()
                > Return
                > End If
                > Next
                >[/color]
                frmAddUser.Show ()

                I hope this helps,

                Cor


                Comment

                • Armin Zingler

                  #9
                  Re: Cannot open the form

                  "Vivek" <viveks@xtra.co .nz> schrieb[color=blue]
                  > If (frmAddUser.IsD isposed) Then[/color]

                  if frmadduser is nothing orelse frmaduser.isdis posed then


                  Armin

                  Comment

                  Working...