By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,934 Members | 1,352 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,934 IT Pros & Developers. It's quick & easy.

Overlapping Group Boxes

P: n/a
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 selectedindexchanged 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?

Sep 25 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Sep 25, 10:27 am, za...@construction-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 selectedindexchanged 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 SelectedIndexChanged:

If Me.ComboBox1.Text = "B" Then
Me.GroupBox1.Visible = False
Me.GroupBox2.Visible = True
Else
Me.GroupBox1.Visible = True
Me.GroupBox2.Visible = 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

Sep 25 '07 #2

P: n/a
On Sep 25, 11:29 am, rowe_newsgroups <rowe_em...@yahoo.comwrote:
On Sep 25, 10:27 am, za...@construction-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 selectedindexchanged 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 SelectedIndexChanged:

If Me.ComboBox1.Text = "B" Then
Me.GroupBox1.Visible = False
Me.GroupBox2.Visible = True
Else
Me.GroupBox1.Visible = True
Me.GroupBox2.Visible = 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.

Sep 25 '07 #3

P: n/a
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.


<za***@construction-imaging.comskrev i meddelandet
news:11**********************@50g2000hsm.googlegro ups.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 selectedindexchanged 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?

Sep 25 '07 #4

P: n/a
JB
On 25 Sep, 21:04, "Johnny Jörgensen" <j...@altcom.sewrote:
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...@construction-imaging.comskrev i meddelandetnews:11**********************@50g2000hs m.googlegroups.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 selectedindexchanged 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.designer.vb file which is automatically generated.
In there just search for reference to you Group Box. If you see a line
like Me.GrpBx1.Controls.Add(Me.GrpBx2) 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
Sep 26 '07 #5

P: n/a
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 selectectedindexchanged event, use the
BringToFront method of the combobox you want to show. You won't have to use
the visible properties.
"za***@construction-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 selectedindexchanged 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?

Sep 28 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.