-
Dec 5th, 2020, 05:40 PM
#1
Thread Starter
New Member
Project with many panels
Hi everybody,
I’ m trying to code an application with a lot of menus (9-10).
It’s possible to make this with panels and to bring in front or back.
But, for me it’s difficult to manage many panels, i need to move them for add controls and code. I spent m’y life to find good panel add and replace it.
Do you have tips for this problem ?
How to navigate in many panels and add controls without moving their position.
Thanks
-
Dec 5th, 2020, 07:31 PM
#2
Re: Project with many panels
I guess you could right click on the top panel and select "Send to Back", until you get to the one you want.
You might also be able to use the "Document Outline" window to pull the one you want to the front.
I'm sort of wondering how you keep the panels from becoming the child of another panel if they fully overlap.
Last edited by passel; Dec 5th, 2020 at 07:38 PM.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Dec 5th, 2020, 09:09 PM
#3
Re: Project with many panels
What you trying to do is easy. You can add as many Panels as you want to the form, select them all, open the Properties window and then just enter a value for the Size and Location properties. Each Panel will then occupy the same area without any being a child of the other. If you already have some Panels on the form and want to add another, simply select the form first, so it is the current parent, and then double-click the Panel in the Toolbox. You can then edit the Size and Location of the Panel in the Properties window. Just be sure to never drag and drop these Panels in the designer or you'll likely end up with one inside another.
To manage them, just open the Document Outline window. Controls that are in front of their siblings are listed before them in the Document Outline window. If you want to work on a particular Panel then you simply select it in that window and click the up-arrow button until that Panel is above all the others. If you can identify each Panel visually, which may be possible once they all have child controls, you can right-click the one that is visible and select Send To Back. That is equivalent to using the down-arrow all the way in the Document Outline window. You can keep doing that until the one you want is at the front. Just make sure that you give that one another click to select it, because a control is still selected after being sent to the back.
-
Dec 6th, 2020, 10:19 AM
#4
Re: Project with many panels
Have you considered using a TabControl for this purpose? You can add as many TabPages as you like and each page behaves much like a panel. Clicking on a tab brings the corresponding page to the front.
BB
-
Dec 6th, 2020, 11:49 AM
#5
Re: Project with many panels
I actually prefer the many panels approach to the tab control once the number of panels gets above a certain number. When the number of tab controls gets so great that two rows of tabs are necessary, I find that design to be pretty busy, and navigation between panels using a menu, wizard-style navigation, or something like that, feels superior to me.
My usual boring signature: Nothing
-
Dec 6th, 2020, 12:55 PM
#6
Re: Project with many panels
I agree, the standard MultiLine implementation leaves a bit to be desired. But as long as you stick to the Multiline=False and Aligment Top or Bottom, there's a nice little forward-back arrow when there are too many tabs to fit the panel width.
Not that I have an axe to grind for the standard TabControl. There are better custom implementations in our VB.Net CodeBank (not to mention WPF which I didn't did I?). Anyway there are countless other ways of making a page navigator. As well as the wizard style, you could for example choose a ToolStrip with image/text buttons etc. Whatever you are already familiar with usually turns out to be "the most intuitive".
BB
-
Dec 6th, 2020, 04:09 PM
#7
Thread Starter
New Member
Re: Project with many panels
Hi,
Thanks a lot for all the answers, i prefere me too the Multipanel than the Tabcontrol, because of the aesthetics.
The "Document Outline" window work well.
I have a another litle question, I make one page with 2 panels because 2 different color, like in the picture :
If i use the "Document Outline" window the panels move separately or it's one page for me.
An advise for this ?
Thanks,
Last edited by kar2013; Dec 6th, 2020 at 04:12 PM.
-
Dec 6th, 2020, 04:24 PM
#8
Re: Project with many panels
Well, unless you show the two panels separately, this might be a case where you would want to nest one panel inside the other so they will move together.
"Anyone can do any amount of work, provided it isn't the work he is supposed to be doing at that moment" Robert Benchley, 1930
-
Dec 6th, 2020, 04:41 PM
#9
Thread Starter
New Member
Re: Project with many panels
Originally Posted by passel
Well, unless you show the two panels separately, this might be a case where you would want to nest one panel inside the other so they will move together.
Passel thanks for your answer, i try to nest the top panel inside the other with dock = top
But the move separately in « document outline » Windows
-
Dec 6th, 2020, 06:27 PM
#10
Re: Project with many panels
I'm not sure I completely understand what you mean but, as far as the Document Outline window goes, you can only ever select one component at a time. If you want to select multiple controls at a time then you have to do that on the design surface itself. If all your Panels occupy the same area, you can only select one of them or all of them, not some of them.
-
Dec 7th, 2020, 02:11 AM
#11
Thread Starter
New Member
Re: Project with many panels
Originally Posted by jmcilhinney
I'm not sure I completely understand what you mean but, as far as the Document Outline window goes, you can only ever select one component at a time. If you want to select multiple controls at a time then you have to do that on the design surface itself. If all your Panels occupy the same area, you can only select one of them or all of them, not some of them.
Tanks for you answer, i have 10 pages, each page it's constituate with 2 panels (top an body) in order to have 2 differents colors, in total 20 élements.
It's difficult to me move all the elements in the correct order.
If it's not possible i have to find new way or to understand better how Document Outline window is working.
Last edited by kar2013; Dec 7th, 2020 at 02:21 AM.
-
Dec 7th, 2020, 02:26 AM
#12
Re: Project with many panels
What's a "page"? What is the relationship among these pages? Please provide a FULL and CLEAR explanation of the problem. If a "page" is a Panel and they all occupy the same area then just click and drag on your form to select them all and then click and drag to move them all as a unit. This is pretty standard behaviour for any visual layout tool.
-
Dec 7th, 2020, 05:18 AM
#13
Thread Starter
New Member
Re: Project with many panels
Originally Posted by jmcilhinney
What's a "page"? What is the relationship among these pages? Please provide a FULL and CLEAR explanation of the problem. If a "page" is a Panel and they all occupy the same area then just click and drag on your form to select them all and then click and drag to move them all as a unit. This is pretty standard behaviour for any visual layout tool.
I'm sorry if my explanations are not clear.
All the pages occupy the same area, but one page it's make with two panels in order to obtain 2 areas with different colors (just for the style).
which makes 20 panels (Top+body * 10).
I use buttons events to change page.
My problem is in the coding phase, i'm looking for tips/advises to change page easely (for move, add controls).
When i do this with the document outline windows, the panels are mixed in the wrong order (for exemple Panel_1_Top with Panel_1_body)
Sorry for my english,
-
Dec 7th, 2020, 06:07 AM
#14
Re: Project with many panels
Hello,
Why not create a custom control based on a groupbox containing 2 panels ? It should be easier to manipulate, shouldn't?
something like that
vb.net 2010 Code:
Public Class Doublepanel Inherits GroupBox Dim p1 As New Panel With {.Width = 300, .Height = 100, .BackColor = Color.CadetBlue} Dim p2 As New Panel With {.Width = 300, .Height = 250, .BackColor = Color.Blue} Public Property P1color() As Color Get Return p1.BackColor End Get Set(ByVal value As Color) p1.BackColor = value End Set End Property Public Property P2color() As Color Get Return p2.BackColor End Get Set(ByVal value As Color) p2.BackColor = value End Set End Property Public Sub New() Me.Height = 350 Me.Width = 300 Me.Controls.Add(p1) Me.Controls.Add(p2) p1.Top = 0 p1.Left = 0 p2.Top = 100 p2.Left = 0 End Sub Private Sub Doublepanel_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize p1.Width = Width p1.Height = CInt(Height / 4) p2.Height = Height - p1.Height p2.Width = Width p2.Top = p1.Height End Sub End Class
regards
Last edited by Delaney; Dec 7th, 2020 at 06:19 AM.
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Dec 7th, 2020, 06:32 AM
#15
Thread Starter
New Member
Re: Project with many panels
Originally Posted by Delaney
Hello,
Why not create a custom control based on a groupbox containing 2 panels ? It should be easier to manipulate, shouldn't?
regards
Thanks Delaney,
If i use this solution, how to add easely controls?
Last edited by kar2013; Dec 7th, 2020 at 06:58 AM.
-
Dec 7th, 2020, 09:51 AM
#16
Re: Project with many panels
if you add the controls directly in the new custom control, it will be add to the groupbox, not to the panel. In this case you need to set the parent by code :
Code:
buttonX.parent=doupblepanel.controls(0) 'or 1 (in the form.load event for example)
or you can create the button (or other control) directly by code
Code:
doublepanel.control(0 or 1).controls.add( new button with{.name="buttonx",.text="essais",.backcolor=color.blue})
.
for allowing the 2 panel to be accessible at design time, I am still looking at it( I found here some clues : https://www.vbforums.com/showthread....custom-control )
Last edited by Delaney; Dec 7th, 2020 at 09:55 AM.
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Dec 7th, 2020, 02:29 PM
#17
Re: Project with many panels
You can use the that Form is derived from Control and can be inserted in another container control like Panel as normal control.
Split your panels into several forms - 10 or 100 - its easy to manage now. You will need code that shows the active "panel" in your main form.
Inside each "panel" form you can place your panels and arrange controls as you wish.
Example routine where you pass the form as parameter to put inside MainPanel:
VB.NET Code:
Private Sub PutFormInPanel(ByVal frm As Form)
frm.TopLevel = False
frm.FormBorderStyle = FormBorderStyle.None
frm.Dock = DockStyle.Fill
MainPanel.Controls.Clear()
MainPanel.Controls.Add(frm)
frm.Show()
End Sub
The idea is to remove form border as it is useless in this case, set dock to fill parent, clear all controls in panel and add the form as child.
You may need to add some logic when you change panels if there will be interaction between different forms. You can do that by exposing events in "panel" forms that can be hooked by the main controlling form and perform actions to set data in the next "panel" form to be shown.
Having separate "panel" forms you can reuse them and show as normal forms if your app needs that.
-
Dec 8th, 2020, 02:11 AM
#18
Thread Starter
New Member
Re: Project with many panels
Thanks a lot for the answers, i'm trying to add panel and contrôls with code.
-
Dec 8th, 2020, 04:21 AM
#19
Re: Project with many panels
using the Tabcontrol isn't a bad Idea, just remove the Tabs and set for example a Combobox as a Datasource
for selecting the Tabpage.
add a Groupbox or a Panel to each TabPage
here some code for testing
Code:
Public Class Form1
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
TabControl1.SuspendLayout()
TabControl1.SizeMode = TabSizeMode.Fixed
TabControl1.ItemSize = New Size(0, 1)
TabControl1.Appearance = TabAppearance.Buttons
TabControl1.ResumeLayout()
Dim pages = TabControl1.TabPages
Me.ComboBox1.DisplayMember = "Text"
ComboBox1.DataSource = pages
End Sub
Private Sub ComboBox1_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
TabControl1.SelectedIndex = ComboBox1.SelectedIndex
ComboBox1.Focus()
End Sub
End Class
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Dec 8th, 2020, 05:33 AM
#20
Thread Starter
New Member
Re: Project with many panels
Originally Posted by ChrisE
using the Tabcontrol isn't a bad Idea, just remove the Tabs and set for example a Combobox as a Datasource
for selecting the Tabpage.
add a Groupbox or a Panel to each TabPage
here some code for testing
Hi all everybody,
I f i use the tabcontrol, it's possible to mask all the tabs labels?
-
Dec 8th, 2020, 08:08 AM
#21
Re: Project with many panels
I just discovered that SplitContainer control may do exactly what you want : it is 2 assembled panels (at least it is doing what I was trying to code with the groupbox and the 2 panels...)
if you add a tool strip you can go from one page to the other or with a combobox as suggested by ChrisE
Last edited by Delaney; Dec 8th, 2020 at 08:23 AM.
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Dec 8th, 2020, 03:33 PM
#22
Thread Starter
New Member
Re: Project with many panels
Originally Posted by Delaney
I just discovered that SplitContainer control may do exactly what you want : it is 2 assembled panels (at least it is doing what I was trying to code with the groupbox and the 2 panels... )
if you add a tool strip you can go from one page to the other or with a combobox as suggested by ChrisE
Great thanks a lot !!!
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
|