Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

Overlapping Group Boxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zacks@construction-imaging.com - 25 Sep 2007 15:27 GMT
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?
rowe_newsgroups - 25 Sep 2007 16:29 GMT
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
[quoted text clipped - 12 lines]
>
> 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
zacks@construction-imaging.com - 25 Sep 2007 19:55 GMT
> On Sep 25, 10:27 am, za...@construction-imaging.com wrote:
>
[quoted text clipped - 37 lines]
> 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.
Johnny Jörgensen - 25 Sep 2007 20:04 GMT
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.

>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
[quoted text clipped - 12 lines]
>
> Any ideas?
JB - 26 Sep 2007 18:02 GMT
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?
[quoted text clipped - 33 lines]
>
> > 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
Charlie - 28 Sep 2007 20:08 GMT
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.

> 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
[quoted text clipped - 12 lines]
>
> Any ideas?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.