|
-
Mar 3rd, 2009, 09:15 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Multiple Panels instead of Forms
To save from using several different forms in programs. I'd like to make just a few panels to represent each one. Then when I need to display one I just set it to visible or not visible.
For example, a quiz program. The 1st 10 questions are on one panel, the 2nd 10 are on a 2nd panel. They are both identical except different questions.
The problem is, when I try to put them both on the form, they have to be in different areas or else one will go inside the other. How can I keep several panels on one form without them going inside each other, in other words how can I keep them separate?
-
Mar 3rd, 2009, 09:58 PM
#2
Hyperactive Member
Re: [2005] Multiple Panels instead of Forms
You could just keep them small and then resize at runtime.
-
Mar 3rd, 2009, 10:01 PM
#3
Thread Starter
Fanatic Member
Re: [2005] Multiple Panels instead of Forms
That would sort of work, but I was wondering if there was a more direct way to just keep the panels separate. Like some kind of setting to block one panel from being placed in another.
If I did do the resize thing it would make editing the panels take longer.
-
Mar 3rd, 2009, 10:11 PM
#4
Re: [2005] Multiple Panels instead of Forms
I don't think the IDE has a way of preventing that. I played around with locking controls, but that didn't seem to help.
-
Mar 3rd, 2009, 10:14 PM
#5
Thread Starter
Fanatic Member
Re: [2005] Multiple Panels instead of Forms
 Originally Posted by Negative0
I don't think the IDE has a way of preventing that. I played around with locking controls, but that didn't seem to help.
Well perhaps the solution doesn't have to be using Panels. Really I just want a way to do something like that. For instance I may be able to use the tab panel control, I just need a way to hide the tabs at the top and then it's nearly the same concept I'm looking for.
-
Mar 3rd, 2009, 10:16 PM
#6
Hyperactive Member
Re: [2005] Multiple Panels instead of Forms
Okay, I just tried it and I was able to place one panel on top of the other when I lined it up in the top-left corner so that they were directly on top of one another. You can tell when the little rectangle indicating that you'll be adding the panel as a child of the one beneath disappears.
-
Mar 3rd, 2009, 10:18 PM
#7
Hyperactive Member
Re: [2005] Multiple Panels instead of Forms
Multiple panels aside, if they are identical is there any reason to not just use one panel and update the questions when switching between the two?
-
Mar 4th, 2009, 05:35 PM
#8
Thread Starter
Fanatic Member
Re: [2005] Multiple Panels instead of Forms
 Originally Posted by wy125
Multiple panels aside, if they are identical is there any reason to not just use one panel and update the questions when switching between the two?
In my example no, but that was just an example. I have had cases where I wanted to use the same-sized form but had different content on the panels. But if it was a quiz form you are correct.
I can try lining up the panels, but to edit one I will have to move it and in doing that it may go back inside. I'll have to see if dragging it out just enough to line up with the others will pull it out again (which is what I want).
EDIT: Ya it works! Even if I first place one panel in another, just dragging it out to line up with it will pull it out from the previous one. Thanks for solving that!
-
Mar 4th, 2009, 05:51 PM
#9
Re: [RESOLVED] [2005] Multiple Panels instead of Forms
Here's another solution: Place the panels wherever you want during design time, and don't use Hide/Unhide to show them. For PDA programs, forms take significant time to load, so I use lots of panels on a single form rather than lots of forms. I set the Left property of each panel correctly in the form Load event, but set the Top property to a number so high that the panel is off the bottom of the screen. Whenever I want to display a panel, I change the Top property to 0 (or whatever would be appropriate in your case). Since I am setting the Left property in the Load, and the Top property here and there, where the panels are located at design time is irrelevant, since they will be moved into place at runtime.
I have more discussion of that technique in the Mobile Development section of the forum, though I haven't laid it out thoroughly in a couple years, so the threads that hold the info are a bit old.
My usual boring signature: Nothing
 
-
Mar 4th, 2009, 06:13 PM
#10
Thread Starter
Fanatic Member
Re: [RESOLVED] [2005] Multiple Panels instead of Forms
I thought of that but you would have to put the panels side-by-side in Design Mode otherwise one would go inside the other. Then to edit you would have to make your form larger than you wanted. Unless when you change the position of one that is inside the other during run-time will actually pull it out, I don't think that would work as if a panel inside another is moved outside the bounds of the first one, it will simply appear as invisible.
-
Mar 4th, 2009, 07:23 PM
#11
Re: [RESOLVED] [2005] Multiple Panels instead of Forms
They don't have to be side-by side, they just wouldn't be able to overlap exactly. As long as they are only partial overlaps they work fine.
Sounds like you have it solved, though.
My usual boring signature: Nothing
 
-
Mar 4th, 2009, 08:39 PM
#12
Thread Starter
Fanatic Member
Re: [RESOLVED] [2005] Multiple Panels instead of Forms
 Originally Posted by Shaggy Hiker
They don't have to be side-by side, they just wouldn't be able to overlap exactly. As long as they are only partial overlaps they work fine.
Sounds like you have it solved, though.
Well I think I will use the other way, but I'm interested in hearing any other possibility. If they overlapped, wouldn't it just put it inside the other? How can you overlap them while keeping them separate? That's like going back to my first question, asking how you did that. Is there something about overlapping causing one to go into the other that I'm overlooking? (I don't mean any of that to sound rude if it does, I'm just not seeing it).
-
Mar 4th, 2009, 10:14 PM
#13
Re: [RESOLVED] [2005] Multiple Panels instead of Forms
I had no problem overlapping them during design, though I do seem to remember that if they overlapped too much they would embed rather than overlap. I had a couple that I was working on, then have the rest in a heap. The form was as large as I could make it, though. The form can be resized when run, but for a PDA there was no advantage to resizing the form, as I just wanted a form that was at least bigger than the screen size, if not even larger.
My usual boring signature: Nothing
 
-
Mar 5th, 2009, 05:18 AM
#14
Re: [RESOLVED] [2005] Multiple Panels instead of Forms
Have a look here:
http://www.vbforums.com/showthread.php?t=558143
Or here (same thing):
http://dotnetrix.co.uk/custom.htm
It's a "PanelManager" control that allows you to add/remove panels like you can with a TabControl. You can use the SelectedPanel property to switch the right panel to the front. All that is done internally, so you don't need to worry about positioning, making them visible etc...
It was also the basis for my WizardControl (see signature).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|