Odd ShowDialog problem

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

    #1

    Odd ShowDialog problem

    I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
    button on that form pops up a FolderBrowserDi alog. As soon as the FBD
    is closed, either by selecting or by cancel, the form exits. Not the
    behavior that I was hoping for. Did I mess something up or is this the
    way that it works?
  • Chris

    #2
    Re: Odd ShowDialog problem

    dgk wrote:[color=blue]
    > I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
    > button on that form pops up a FolderBrowserDi alog. As soon as the FBD
    > is closed, either by selecting or by cancel, the form exits. Not the
    > behavior that I was hoping for. Did I mess something up or is this the
    > way that it works?[/color]

    Can we see some simplified code that shows the problem?

    chris

    Comment

    • dgk

      #3
      Re: Odd ShowDialog problem

      On Sun, 31 Jul 2005 23:57:43 -0400, Chris <no@spam.com> wrote:
      [color=blue]
      >dgk wrote:[color=green]
      >> I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
      >> button on that form pops up a FolderBrowserDi alog. As soon as the FBD
      >> is closed, either by selecting or by cancel, the form exits. Not the
      >> behavior that I was hoping for. Did I mess something up or is this the
      >> way that it works?[/color]
      >
      >Can we see some simplified code that shows the problem?
      >
      >chris[/color]


      In the main form (during load if app settings aren't created yet):

      Dim frmOptions As New frmOpts
      Dim RCF As DialogResult = frmOptions.Show Dialog
      If RCF = DialogResult.Ca ncel Then Environment.Exi t(1)
      frmOptions.Clos e()


      In frmOptions I declare this:

      Private FBD As New System.Windows. Forms.FolderBro wserDialog

      and in a button click event do this:

      Private Sub btnBrowse_Click (ByVal sender As System.Object, ByVal e
      As System.EventArg s) Handles btnBrowse.Click

      FBD.ShowNewFold erButton = True
      Dim J As DialogResult = FBD.ShowDialog
      End Sub

      Click on the button, the Folder dialog pops up. Click either Ok or
      Cancel and the folderbrowser exits, and so does the form. I can likely
      stop it in OnClosing since that code is certainly firing, but I have
      no idea why it is happening.

      Comment

      • Cor Ligthert [MVP]

        #4
        Re: Odd ShowDialog problem

        DGK,

        How do you set that OK in your code.

        Return dialogresult.OK as the button OK is clicked will probably fix the
        job.

        Be aware that there are some bugs in this by setting the button using the
        designer to OK.
        (I am not sure anymore what it was, so I never use this)

        I hope this helps,

        Cor


        Comment

        • dgk

          #5
          Re: Odd ShowDialog problem

          On Mon, 1 Aug 2005 07:06:19 +0200, "Cor Ligthert [MVP]"
          <notmyfirstname @planet.nl> wrote:
          [color=blue]
          >DGK,
          >
          >How do you set that OK in your code.
          >
          >Return dialogresult.OK as the button OK is clicked will probably fix the
          >job.
          >
          >Be aware that there are some bugs in this by setting the button using the
          >designer to OK.
          >(I am not sure anymore what it was, so I never use this)
          >
          >I hope this helps,
          >
          >Cor
          >[/color]

          I'm not sure that I understand this. I do set dialogresult.OK in the
          OK button on the form, which is where the settings are actually
          updated, but the OK that is from the FolderBrowserDi alog is part of
          the sealed class and I can't do anything about it. Apparently
          selecting either button on the FBD object is somehow satisifying the
          need for a dialog result for the form. But if that was so, I wouldn't
          be the first one writing about it. I've looked through two years of
          messages and there are quite a few on ShowDialog but none mention
          this.

          Comment

          • Oenone

            #6
            Re: Odd ShowDialog problem

            dgk wrote:[color=blue]
            > I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
            > button on that form pops up a FolderBrowserDi alog. As soon as the FBD
            > is closed, either by selecting or by cancel, the form exits.[/color]

            What is the DialogResult property of the button on your form set to? If it's
            something other than None, this could result in the behaviour you described.

            --

            (O)enone



            Comment

            • dgk

              #7
              Re: Odd ShowDialog problem

              On Mon, 1 Aug 2005 13:30:48 +0100, "Oenone" <oenone@nowhere .com>
              wrote:
              [color=blue]
              >dgk wrote:[color=green]
              >> I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
              >> button on that form pops up a FolderBrowserDi alog. As soon as the FBD
              >> is closed, either by selecting or by cancel, the form exits.[/color]
              >
              >What is the DialogResult property of the button on your form set to? If it's
              >something other than None, this could result in the behaviour you described.[/color]

              I hadn't set the DialogResult to anything yet. I just tried setting it
              to None in Load and still got the same behavior. So I made a new
              project with just the essentials, one form showing another with
              ShowDialog(Me) and having a button on that form pop up the
              FolderDialogBro wser. It worked fine. So something else is weird in my
              project. Maybe a custom control that I'm also using on that form is
              causing problems? I'll gut it and see what happens.

              Comment

              • dgk

                #8
                Re: Odd ShowDialog problem

                On Mon, 01 Aug 2005 13:23:14 GMT, dgk
                <sonicechoes-spamless@zero-spam-hotmail.com> wrote:
                [color=blue]
                >On Mon, 1 Aug 2005 13:30:48 +0100, "Oenone" <oenone@nowhere .com>
                >wrote:
                >[color=green]
                >>dgk wrote:[color=darkred]
                >>> I'm showing a form using ShowDialog (VB2003 in Visual Studio), and a
                >>> button on that form pops up a FolderBrowserDi alog. As soon as the FBD
                >>> is closed, either by selecting or by cancel, the form exits.[/color]
                >>
                >>What is the DialogResult property of the button on your form set to? If it's
                >>something other than None, this could result in the behaviour you described.[/color]
                >
                >I hadn't set the DialogResult to anything yet. I just tried setting it
                >to None in Load and still got the same behavior. So I made a new
                >project with just the essentials, one form showing another with
                >ShowDialog(M e) and having a button on that form pop up the
                >FolderDialogBr owser. It worked fine. So something else is weird in my
                >project. Maybe a custom control that I'm also using on that form is
                >causing problems? I'll gut it and see what happens.[/color]


                Ok, I have now added a new form and built the code back up until it is
                a duplicate of the original problem form. It works fine. I have no
                idea what is different but I'm on vacation today and I'M GOING TO THE
                BEACH NOW. I just couldn't go until I had this fixed.

                Comment

                Working...