Overlapping Group Boxes

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • zacks@construction-imaging.com

    #1

    Overlapping Group Boxes

    I am having a strange issue with an application written in .NET 2.0.
    Actually it is in VB.NET but I think my problem is not language
    specific, but a .NET Framework issue.

    On a form I have a Combo Box populated with two items. There are two
    Group Boxes on the form with different sets of controls in each. They
    both are the same size and are located at the same place. Which Group
    Box is visible depends on the item selected in the combo box.

    I have found that switching the visible property between them in the
    combo box's selectedindexch anged event only works if the group box
    that starts off as not visible is "under" the group box that starts
    off as visible. If they are the other way around, the group box now on
    the bottom will never appear.

    Any ideas?

  • rowe_newsgroups

    #2
    Re: Overlapping Group Boxes

    On Sep 25, 10:27 am, za...@construct ion-imaging.com wrote:
    I am having a strange issue with an application written in .NET 2.0.
    Actually it is in VB.NET but I think my problem is not language
    specific, but a .NET Framework issue.
    >
    On a form I have a Combo Box populated with two items. There are two
    Group Boxes on the form with different sets of controls in each. They
    both are the same size and are located at the same place. Which Group
    Box is visible depends on the item selected in the combo box.
    >
    I have found that switching the visible property between them in the
    combo box's selectedindexch anged event only works if the group box
    that starts off as not visible is "under" the group box that starts
    off as visible. If they are the other way around, the group box now on
    the bottom will never appear.
    >
    Any ideas?
    I'd hate to say this, but I can't reproduce this here. Here's what I
    did:

    Created New WinForms project
    Added Combobox (ComboBox1)
    Added two item's to ComboBox1's items collection ("A" and "B")
    Added GroupBox (GroupBox1)
    Added GroupBox (GroupBox2)
    Set GroupBox2's location equal to GroupBox1's location
    Set GroupBox2's Visible property equal to False
    Added the following to ComboBox1's SelectedIndexCh anged:

    If Me.ComboBox1.Te xt = "B" Then
    Me.GroupBox1.Vi sible = False
    Me.GroupBox2.Vi sible = True
    Else
    Me.GroupBox1.Vi sible = True
    Me.GroupBox2.Vi sible = False
    End If

    Everything appears to work fine, the GroupBox's are swapping places
    just fine. Did I do something wrong in my steps?

    Thanks,

    Seth Rowe

    Comment

    • zacks@construction-imaging.com

      #3
      Re: Overlapping Group Boxes

      On Sep 25, 11:29 am, rowe_newsgroups <rowe_em...@yah oo.comwrote:
      On Sep 25, 10:27 am, za...@construct ion-imaging.com wrote:
      >
      >
      >
      >
      >
      I am having a strange issue with an application written in .NET 2.0.
      Actually it is in VB.NET but I think my problem is not language
      specific, but a .NET Framework issue.
      >
      On a form I have a Combo Box populated with two items. There are two
      Group Boxes on the form with different sets of controls in each. They
      both are the same size and are located at the same place. Which Group
      Box is visible depends on the item selected in the combo box.
      >
      I have found that switching the visible property between them in the
      combo box's selectedindexch anged event only works if the group box
      that starts off as not visible is "under" the group box that starts
      off as visible. If they are the other way around, the group box now on
      the bottom will never appear.
      >
      Any ideas?
      >
      I'd hate to say this, but I can't reproduce this here. Here's what I
      did:
      >
      Created New WinForms project
      Added Combobox (ComboBox1)
      Added two item's to ComboBox1's items collection ("A" and "B")
      Added GroupBox (GroupBox1)
      Added GroupBox (GroupBox2)
      Set GroupBox2's location equal to GroupBox1's location
      Set GroupBox2's Visible property equal to False
      Added the following to ComboBox1's SelectedIndexCh anged:
      >
      If Me.ComboBox1.Te xt = "B" Then
      Me.GroupBox1.Vi sible = False
      Me.GroupBox2.Vi sible = True
      Else
      Me.GroupBox1.Vi sible = True
      Me.GroupBox2.Vi sible = False
      End If
      >
      Everything appears to work fine, the GroupBox's are swapping places
      just fine. Did I do something wrong in my steps?
      I appreciate you being so thorough. The only difference I can see is
      that the default visible property for both group boxes is true. The
      visble property of the group box that isn't the "default" is set to
      false in the form's Load event. Can't really say how that could cause
      things to be different, though.

      Also, again don't know if it makes a difference, but both group boxes
      in my app have several controls, a mix of comboboxes, textboxes,
      checkboxes and command buttons.

      Comment

      • Johnny Jörgensen

        #4
        Re: Overlapping Group Boxes

        Could it be that one groupbox is actually owned by the other groupbox
        instead of the parentform?

        You can check that using the Class View window (View|Class View)

        There you should see your form (eg. Form1 or whatever). If you click that
        you can see all the controls in Form1 (amongst other things). There you
        should be able too see both Groupboxes. What I suspect is that you will only
        see one of them, and if you click that one, you will see the other one as a
        child control of the first one.

        It's easily done if you arrange your controls using drag and drop.

        If that's not the problem, I'm afraid I haven't got a clue... ;-) Then you
        might have to post some cod efor us to look at.

        Cheers,
        Johnny J.




        <zacks@construc tion-imaging.comskre v i meddelandet
        news:1190730434 .128844.207740@ 50g2000hsm.goog legroups.com...
        >I am having a strange issue with an application written in .NET 2.0.
        Actually it is in VB.NET but I think my problem is not language
        specific, but a .NET Framework issue.
        >
        On a form I have a Combo Box populated with two items. There are two
        Group Boxes on the form with different sets of controls in each. They
        both are the same size and are located at the same place. Which Group
        Box is visible depends on the item selected in the combo box.
        >
        I have found that switching the visible property between them in the
        combo box's selectedindexch anged event only works if the group box
        that starts off as not visible is "under" the group box that starts
        off as visible. If they are the other way around, the group box now on
        the bottom will never appear.
        >
        Any ideas?
        >

        Comment

        • JB

          #5
          Re: Overlapping Group Boxes

          On 25 Sep, 21:04, "Johnny Jörgensen" <j...@altcom.se wrote:
          Could it be that one groupbox is actually owned by the other groupbox
          instead of the parentform?
          >
          You can check that using the Class View window (View|Class View)
          >
          There you should see your form (eg. Form1 or whatever). If you click that
          you can see all the controls in Form1 (amongst other things). There you
          should be able too see both Groupboxes. What I suspect is that you will only
          see one of them, and if you click that one, you will see the other one asa
          child control of the first one.
          >
          It's easily done if you arrange your controls using drag and drop.
          >
          If that's not the problem, I'm afraid I haven't got a clue... ;-) Then you
          might have to post some cod efor us to look at.
          >
          Cheers,
          Johnny J.
          >
          <za...@construc tion-imaging.comskre v i meddelandetnews :1190730434.128 844.207740@50g2 000hsm.googlegr oups.com...
          >
          I am having a strange issue with an application written in .NET 2.0.
          Actually it is in VB.NET but I think my problem is not language
          specific, but a .NET Framework issue.
          >
          On a form I have a Combo Box populated with two items. There are two
          Group Boxes on the form with different sets of controls in each. They
          both are the same size and are located at the same place. Which Group
          Box is visible depends on the item selected in the combo box.
          >
          I have found that switching the visible property between them in the
          combo box's selectedindexch anged event only works if the group box
          that starts off as not visible is "under" the group box that starts
          off as visible. If they are the other way around, the group box now on
          the bottom will never appear.
          >
          Any ideas?
          Hi,

          I had similar problems with overlapping panels and group boxes.
          To be sure one group box isn't owned by the other go to the
          yourForm.design er.vb file which is automatically generated.
          In there just search for reference to you Group Box. If you see a line
          like Me.GrpBx1.Contr ols.Add(Me.GrpB x2) that means that GrpBx2 is
          actually owned by GrpBx1.
          It often happens when you place your controls at the same position
          with the GUI.
          Just remove that line from the file and replace it with something like
          Me.Controls.Add (Me.GrpBx2). Then GrpBx will be owned by the form
          instead.

          JB


          Comment

          • =?Utf-8?B?Q2hhcmxpZQ==?=

            #6
            RE: Overlapping Group Boxes

            If you have not yet resolved this...

            Try this
            In the form designer, set the GroupBoxes apart, to be sure one does not own
            the other. In form_load, set the location and size properties of one equal
            to the other. In the ComboBox selectectedinde xchanged event, use the
            BringToFront method of the combobox you want to show. You won't have to use
            the visible properties.


            "zacks@construc tion-imaging.com" wrote:
            I am having a strange issue with an application written in .NET 2.0.
            Actually it is in VB.NET but I think my problem is not language
            specific, but a .NET Framework issue.
            >
            On a form I have a Combo Box populated with two items. There are two
            Group Boxes on the form with different sets of controls in each. They
            both are the same size and are located at the same place. Which Group
            Box is visible depends on the item selected in the combo box.
            >
            I have found that switching the visible property between them in the
            combo box's selectedindexch anged event only works if the group box
            that starts off as not visible is "under" the group box that starts
            off as visible. If they are the other way around, the group box now on
            the bottom will never appear.
            >
            Any ideas?
            >
            >

            Comment

            Working...