Z-order not working for stacked panels

R

Ruben L

I'm upgrading/rewriting an apllication written in VB6 to VB2008.
The main form had an outlook-like navigation with a vertical buttonbar in
the left side of the form and a bunch of frames with controls on them in the
main area. All these frames were placed exactly on top of each other, and
pushing a button on the buttonbar made a specific frame come to the fore
(using z-order). it worked nicely for the user - no flickering with forms
being loaded etc.
BUT, in VB6 it was a pain to edit the form (adding new controls etc) since
all the frames belonged to the same form and thus all the frames' controls
were likewise part of the same form making it hard to locate what needed to
be changed, and Z-order wasn't working too good at design time.

In VB2008: On a new form, placed a splitcontainer vertically: OK.
Two new panels placed on top of right panel (same size and different
backcolors) and a few controls (labels) added to each.
Problem: It's not possible to swap those two panels at design time. The
Bring to front/back does not work! Selecting the back panel and chosing Bring
to front does nothing. Selecting the top panel and chosing Send to Back makes
the label from the back panel visible - but NOT the rest of the panel.

If you should build an Outlook look-alike form what road would you take?
(The post below suggest making a form equivalent to a panel and load that
form/embed it, but I'm hesitant about loading and unloading forms due to
heavy datagrids on the forms. Using panels there is only a delay starting up)
http://msdn.microsoft.com/newsgroup...otnet-frmwrk&lang=en&cr=US&sloc=en-us&m=1&p=1

Any ideas or best practices?

Thanks
/Ruben
 
M

Michael C

Ruben L said:
In VB2008: On a new form, placed a splitcontainer vertically: OK.
Two new panels placed on top of right panel (same size and different
backcolors) and a few controls (labels) added to each.
Problem: It's not possible to swap those two panels at design time. The
Bring to front/back does not work! Selecting the back panel and chosing
Bring
to front does nothing. Selecting the top panel and chosing Send to Back
makes
the label from the back panel visible - but NOT the rest of the panel.

Sounds like all the controls are not children of the panel.
If you should build an Outlook look-alike form what road would you take?

Usercontrols. You should have done it this way in VB6 as well. I did
something similar in vb6 recently and it worked really well. It'd work even
better in dot net. :)

Michael
 
R

Ruben L

Michael, what would the benefit be of developing several user controls (to be
used in this project only) compared to the develop-several-forms approach? It
seems much easier to design forms - and I guess user controls will still need
to load data just as separate forms(?)
 
M

Michael C

Ruben L said:
Michael, what would the benefit be of developing several user controls (to
be
used in this project only) compared to the develop-several-forms approach?

You can't host a form inside another form (at least not without hacks).
It
seems much easier to design forms

It's pretty much the same really, you just drag and drop controls, move them
around etc.
- and I guess user controls will still need
to load data just as separate forms(?)

Not necessarily, you could a class that holds the required data and pass an
instance of that class to each control. Generally you'd create an interface
for each of the controls to implement.


Michael
 
R

Ruben L

Thanks Michael. It looks like that's the right track!

For other newbies: Project - Add User Control - let the user Control
template remain selected and change name - Add - and you have a new Form
Designer Window. Do your stuff as you would with a form and then Build the
project.
The user control will now be available in your toolbox in a "MyProjects
Components" section - visible when in form design.
For the Outlook-a like - situation mentioned above: add the user controls on
top of each other and use BringToFront/back. Works so far :)
 
M

Michael C

Ruben L said:
Thanks Michael. It looks like that's the right track!

For other newbies: Project - Add User Control - let the user Control
template remain selected and change name - Add - and you have a new Form
Designer Window. Do your stuff as you would with a form and then Build the
project.
The user control will now be available in your toolbox in a "MyProjects
Components" section - visible when in form design.
For the Outlook-a like - situation mentioned above: add the user controls
on
top of each other and use BringToFront/back. Works so far :)

One other thing worth considering is adding an interface to each of these
controls. For example, if every control needs to have a method called
PopulateData then you would define an interface like this

public interface IWhatever
{
void PopulateData();
}

then in your usercontrols add this

public MyUsercontrol : UserControl, IWhatever

then right click IWhatever and select Implement.

This way all your controls can be treated as an IWhatever and you can define
an IWhatever array to store them in.

Michael
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top