Results 1 to 22 of 22

Thread: Project with many panels

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    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

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    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

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    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.

  4. #4
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    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

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    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

  6. #6
    PowerPoster boops boops's Avatar
    Join Date
    Nov 2008
    Location
    Holland/France
    Posts
    3,201

    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

  7. #7

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    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 :

    Name:  test_appli.png
Views: 569
Size:  3.2 KB

    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.

  8. #8
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    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

  9. #9

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Quote Originally Posted by passel View Post
    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

  10. #10
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    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.

  11. #11

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Quote Originally Posted by jmcilhinney View Post
    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.

  12. #12
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    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.

  13. #13

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Quote Originally Posted by jmcilhinney View Post
    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,

  14. #14
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    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:
    1. Public Class Doublepanel
    2.    Inherits GroupBox
    3.  
    4.    Dim p1 As New Panel With {.Width = 300, .Height = 100, .BackColor = Color.CadetBlue}
    5.    Dim p2 As New Panel With {.Width = 300, .Height = 250, .BackColor = Color.Blue}
    6.  
    7.    Public Property P1color() As Color
    8.       Get
    9.          Return p1.BackColor
    10.       End Get
    11.       Set(ByVal value As Color)
    12.          p1.BackColor = value
    13.       End Set
    14.    End Property
    15.    Public Property P2color() As Color
    16.       Get
    17.          Return p2.BackColor
    18.       End Get
    19.       Set(ByVal value As Color)
    20.          p2.BackColor = value
    21.       End Set
    22.    End Property
    23.  
    24.    Public Sub New()
    25.       Me.Height = 350
    26.       Me.Width = 300
    27.       Me.Controls.Add(p1)
    28.       Me.Controls.Add(p2)
    29.       p1.Top = 0
    30.       p1.Left = 0
    31.       p2.Top = 100
    32.       p2.Left = 0
    33.    End Sub
    34.    Private Sub Doublepanel_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
    35.       p1.Width = Width
    36.       p1.Height = CInt(Height / 4)
    37.       p2.Height = Height - p1.Height
    38.       p2.Width = Width
    39.       p2.Top = p1.Height
    40.    End Sub
    41. 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)

  15. #15

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Quote Originally Posted by Delaney View Post
    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.

  16. #16
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    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)

  17. #17
    Fanatic Member
    Join Date
    Jun 2019
    Posts
    558

    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:
    1. Private Sub PutFormInPanel(ByVal frm As Form)
    2.     frm.TopLevel = False
    3.     frm.FormBorderStyle = FormBorderStyle.None
    4.     frm.Dock = DockStyle.Fill
    5.     MainPanel.Controls.Clear()
    6.     MainPanel.Controls.Add(frm)
    7.  
    8.     frm.Show()
    9. 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.

  18. #18

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Thanks a lot for the answers, i'm trying to add panel and contrôls with code.

  19. #19
    PowerPoster ChrisE's Avatar
    Join Date
    Jun 2017
    Location
    Frankfurt
    Posts
    3,048

    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.

  20. #20

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Quote Originally Posted by ChrisE View Post
    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:
    
    
    Hi all everybody,

    I f i use the tabcontrol, it's possible to mask all the tabs labels?

  21. #21
    Fanatic Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    845

    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)

  22. #22

    Thread Starter
    New Member
    Join Date
    Mar 2020
    Posts
    12

    Re: Project with many panels

    Quote Originally Posted by Delaney View Post
    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
  •  



Click Here to Expand Forum to Full Width