Multiple panels with 'Fill' docking

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve McLellan

    #1

    Multiple panels with 'Fill' docking

    Hi,

    I'm trying to add panels to a parent panel programatically . I'd like them to
    all take up an equal amount of the parent form as it's resized etc. Using
    Docking::Fill obviously causes one panel to expand to fill the entire
    parent, and I can't get a satisfactory result using Anchor - the leftmost
    controls start to take more than their fair share as the parent panel grows
    in size.. Can anyone suggest a way of doing this? Some kind of grid system
    is what I'm looking for I guess. I could achieve this effect with custom
    resizing code but I don't want to have to do that if avoidable.

    Thanks in advance,

    Steve


  • Mathieu Chavoutier

    #2
    Re: Multiple panels with 'Fill' docking


    "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
    de news:enH9%2357J EHA.268@TK2MSFT NGP11.phx.gbl.. .[color=blue]
    > Hi,
    >
    > I'm trying to add panels to a parent panel programatically . I'd like them[/color]
    to[color=blue]
    > all take up an equal amount of the parent form as it's resized etc. Using
    > Docking::Fill obviously causes one panel to expand to fill the entire
    > parent, and I can't get a satisfactory result using Anchor - the leftmost
    > controls start to take more than their fair share as the parent panel[/color]
    grows[color=blue]
    > in size.. Can anyone suggest a way of doing this? Some kind of grid system
    > is what I'm looking for I guess. I could achieve this effect with custom
    > resizing code but I don't want to have to do that if avoidable.[/color]

    I think that Resize is the only way.
    Nevertheless, it doesn't use much lines of code :

    private void resize(object sender, EventArgs e)

    {

    // I have 4 panels, and I want each of them in a corner, and also to take a
    quarter of the screen

    // L is Left, R right, T top and B bottom

    /*********

    * LT * RT *

    *********

    * LB * RB *

    **********/

    LTpanel.Locatio n = new Point(0, 0);

    LTpanel.Width = myPanel.ClientS ize.Width / 2;

    LTpanel.Height = myPanel.ClientS ize.Height / 2;

    LTpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.To p;

    RTpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2, 0);

    RTpanel.Width = RTpanel.Parent. ClientSize.Widt h / 2;

    RTpanel.Height = RTpanel.Parent. ClientSize.Heig ht / 2;

    RTpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.To p;

    LBpanel.Locatio n = new Point(0, RTpanel.Parent. ClientSize.Heig ht / 2);

    LBpanel.Width = LBpanel.Parent. ClientSize.Widt h / 2;

    LBpanel.Height = LBpanel.Parent. ClientSize.Heig ht / 2;

    LBpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.Bo ttom;

    RBpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2,
    RTpanel.Parent. ClientSize.Heig ht / 2);

    RBpanel.Width = RBpanel.Parent. ClientSize.Widt h / 2;

    RBpanel.Height = RBpanel.Parent. ClientSize.Heig ht / 2;

    RBpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.Bo ttom;

    }


    Comment

    • Mathieu Chavoutier

      #3
      Re: Multiple panels with 'Fill' docking


      "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
      de news:enH9%2357J EHA.268@TK2MSFT NGP11.phx.gbl.. .[color=blue]
      > Hi,
      >
      > I'm trying to add panels to a parent panel programatically . I'd like them[/color]
      to[color=blue]
      > all take up an equal amount of the parent form as it's resized etc. Using
      > Docking::Fill obviously causes one panel to expand to fill the entire
      > parent, and I can't get a satisfactory result using Anchor - the leftmost
      > controls start to take more than their fair share as the parent panel[/color]
      grows[color=blue]
      > in size.. Can anyone suggest a way of doing this? Some kind of grid system
      > is what I'm looking for I guess. I could achieve this effect with custom
      > resizing code but I don't want to have to do that if avoidable.[/color]

      I think that Resize is the only way.
      Nevertheless, it doesn't use much lines of code :

      private void resize(object sender, EventArgs e)

      {

      // I have 4 panels, and I want each of them in a corner, and also to take a
      quarter of the screen

      // L is Left, R right, T top and B bottom

      /*********

      * LT * RT *

      *********

      * LB * RB *

      **********/

      LTpanel.Locatio n = new Point(0, 0);

      LTpanel.Width = myPanel.ClientS ize.Width / 2;

      LTpanel.Height = myPanel.ClientS ize.Height / 2;

      LTpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.To p;

      RTpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2, 0);

      RTpanel.Width = RTpanel.Parent. ClientSize.Widt h / 2;

      RTpanel.Height = RTpanel.Parent. ClientSize.Heig ht / 2;

      RTpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.To p;

      LBpanel.Locatio n = new Point(0, RTpanel.Parent. ClientSize.Heig ht / 2);

      LBpanel.Width = LBpanel.Parent. ClientSize.Widt h / 2;

      LBpanel.Height = LBpanel.Parent. ClientSize.Heig ht / 2;

      LBpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.Bo ttom;

      RBpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2,
      RTpanel.Parent. ClientSize.Heig ht / 2);

      RBpanel.Width = RBpanel.Parent. ClientSize.Widt h / 2;

      RBpanel.Height = RBpanel.Parent. ClientSize.Heig ht / 2;

      RBpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.Bo ttom;

      }


      Comment

      • Steve McLellan

        #4
        Re: Multiple panels with 'Fill' docking

        Hi,

        Yeah, but when you've got 'n' panels, it becomes harder. I'm going to have
        to write a custom layout event handler I think.

        Thanks for the reply,

        Steve

        "Mathieu Chavoutier" <NoSpam@NoSpam. org> wrote in message
        news:OGt4AB8JEH A.2756@TK2MSFTN GP10.phx.gbl...[color=blue]
        >
        > "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
        > de news:enH9%2357J EHA.268@TK2MSFT NGP11.phx.gbl.. .[color=green]
        > > Hi,
        > >
        > > I'm trying to add panels to a parent panel programatically . I'd like[/color][/color]
        them[color=blue]
        > to[color=green]
        > > all take up an equal amount of the parent form as it's resized etc.[/color][/color]
        Using[color=blue][color=green]
        > > Docking::Fill obviously causes one panel to expand to fill the entire
        > > parent, and I can't get a satisfactory result using Anchor - the[/color][/color]
        leftmost[color=blue][color=green]
        > > controls start to take more than their fair share as the parent panel[/color]
        > grows[color=green]
        > > in size.. Can anyone suggest a way of doing this? Some kind of grid[/color][/color]
        system[color=blue][color=green]
        > > is what I'm looking for I guess. I could achieve this effect with custom
        > > resizing code but I don't want to have to do that if avoidable.[/color]
        >
        > I think that Resize is the only way.
        > Nevertheless, it doesn't use much lines of code :
        >
        > private void resize(object sender, EventArgs e)
        >
        > {
        >
        > // I have 4 panels, and I want each of them in a corner, and also to take[/color]
        a[color=blue]
        > quarter of the screen
        >
        > // L is Left, R right, T top and B bottom
        >
        > /*********
        >
        > * LT * RT *
        >
        > *********
        >
        > * LB * RB *
        >
        > **********/
        >
        > LTpanel.Locatio n = new Point(0, 0);
        >
        > LTpanel.Width = myPanel.ClientS ize.Width / 2;
        >
        > LTpanel.Height = myPanel.ClientS ize.Height / 2;
        >
        > LTpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.To p;
        >
        > RTpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2, 0);
        >
        > RTpanel.Width = RTpanel.Parent. ClientSize.Widt h / 2;
        >
        > RTpanel.Height = RTpanel.Parent. ClientSize.Heig ht / 2;
        >
        > RTpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.To p;
        >
        > LBpanel.Locatio n = new Point(0, RTpanel.Parent. ClientSize.Heig ht / 2);
        >
        > LBpanel.Width = LBpanel.Parent. ClientSize.Widt h / 2;
        >
        > LBpanel.Height = LBpanel.Parent. ClientSize.Heig ht / 2;
        >
        > LBpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.Bo ttom;
        >
        > RBpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2,
        > RTpanel.Parent. ClientSize.Heig ht / 2);
        >
        > RBpanel.Width = RBpanel.Parent. ClientSize.Widt h / 2;
        >
        > RBpanel.Height = RBpanel.Parent. ClientSize.Heig ht / 2;
        >
        > RBpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.Bo ttom;
        >
        > }
        >
        >[/color]


        Comment

        • Steve McLellan

          #5
          Re: Multiple panels with 'Fill' docking

          Hi,

          Yeah, but when you've got 'n' panels, it becomes harder. I'm going to have
          to write a custom layout event handler I think.

          Thanks for the reply,

          Steve

          "Mathieu Chavoutier" <NoSpam@NoSpam. org> wrote in message
          news:OGt4AB8JEH A.2756@TK2MSFTN GP10.phx.gbl...[color=blue]
          >
          > "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
          > de news:enH9%2357J EHA.268@TK2MSFT NGP11.phx.gbl.. .[color=green]
          > > Hi,
          > >
          > > I'm trying to add panels to a parent panel programatically . I'd like[/color][/color]
          them[color=blue]
          > to[color=green]
          > > all take up an equal amount of the parent form as it's resized etc.[/color][/color]
          Using[color=blue][color=green]
          > > Docking::Fill obviously causes one panel to expand to fill the entire
          > > parent, and I can't get a satisfactory result using Anchor - the[/color][/color]
          leftmost[color=blue][color=green]
          > > controls start to take more than their fair share as the parent panel[/color]
          > grows[color=green]
          > > in size.. Can anyone suggest a way of doing this? Some kind of grid[/color][/color]
          system[color=blue][color=green]
          > > is what I'm looking for I guess. I could achieve this effect with custom
          > > resizing code but I don't want to have to do that if avoidable.[/color]
          >
          > I think that Resize is the only way.
          > Nevertheless, it doesn't use much lines of code :
          >
          > private void resize(object sender, EventArgs e)
          >
          > {
          >
          > // I have 4 panels, and I want each of them in a corner, and also to take[/color]
          a[color=blue]
          > quarter of the screen
          >
          > // L is Left, R right, T top and B bottom
          >
          > /*********
          >
          > * LT * RT *
          >
          > *********
          >
          > * LB * RB *
          >
          > **********/
          >
          > LTpanel.Locatio n = new Point(0, 0);
          >
          > LTpanel.Width = myPanel.ClientS ize.Width / 2;
          >
          > LTpanel.Height = myPanel.ClientS ize.Height / 2;
          >
          > LTpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.To p;
          >
          > RTpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2, 0);
          >
          > RTpanel.Width = RTpanel.Parent. ClientSize.Widt h / 2;
          >
          > RTpanel.Height = RTpanel.Parent. ClientSize.Heig ht / 2;
          >
          > RTpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.To p;
          >
          > LBpanel.Locatio n = new Point(0, RTpanel.Parent. ClientSize.Heig ht / 2);
          >
          > LBpanel.Width = LBpanel.Parent. ClientSize.Widt h / 2;
          >
          > LBpanel.Height = LBpanel.Parent. ClientSize.Heig ht / 2;
          >
          > LBpanel.Anchor = AnchorStyles.Le ft | AnchorStyles.Bo ttom;
          >
          > RBpanel.Locatio n = new Point(myPanel.C lientSize.Width / 2,
          > RTpanel.Parent. ClientSize.Heig ht / 2);
          >
          > RBpanel.Width = RBpanel.Parent. ClientSize.Widt h / 2;
          >
          > RBpanel.Height = RBpanel.Parent. ClientSize.Heig ht / 2;
          >
          > RBpanel.Anchor = AnchorStyles.Ri ght | AnchorStyles.Bo ttom;
          >
          > }
          >
          >[/color]


          Comment

          • Mathieu Chavoutier

            #6
            Re: Multiple panels with 'Fill' docking


            "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
            de news:efExaO8JEH A.272@TK2MSFTNG P11.phx.gbl...[color=blue]
            > Hi,
            >
            > Yeah, but when you've got 'n' panels, it becomes harder. I'm going to have
            > to write a custom layout event handler I think.[/color]

            Perhaps, if you have a list of Panels, you can do a list, and loop

            while (elements_in_th e_list)
            {
            LTpanel.Locatio n = new Point(x * myPanel.ClientS ize.Width / N, x *
            myPanel.ClientS ize.Height / N);
            LTpanel.Width = myPanel.ClientS ize.Width / N;
            LTpanel.Height = myPanel.ClientS ize.Height / N;
            x++;
            }

            And, if it's not only panels, you will have litte changes to do :o)

            Hope that help.


            Comment

            • Mathieu Chavoutier

              #7
              Re: Multiple panels with 'Fill' docking


              "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
              de news:efExaO8JEH A.272@TK2MSFTNG P11.phx.gbl...[color=blue]
              > Hi,
              >
              > Yeah, but when you've got 'n' panels, it becomes harder. I'm going to have
              > to write a custom layout event handler I think.[/color]

              Perhaps, if you have a list of Panels, you can do a list, and loop

              while (elements_in_th e_list)
              {
              LTpanel.Locatio n = new Point(x * myPanel.ClientS ize.Width / N, x *
              myPanel.ClientS ize.Height / N);
              LTpanel.Width = myPanel.ClientS ize.Width / N;
              LTpanel.Height = myPanel.ClientS ize.Height / N;
              x++;
              }

              And, if it's not only panels, you will have litte changes to do :o)

              Hope that help.


              Comment

              • Steve McLellan

                #8
                Re: Multiple panels with 'Fill' docking

                Hi,

                Yeah, I've done a system like that as a layout handler and it seems to work
                fine. Thanks!

                Steve

                "Mathieu Chavoutier" <NoSpam@NoSpam. org> wrote in message
                news:eQ6XL4DKEH A.1264@TK2MSFTN GP12.phx.gbl...[color=blue]
                >
                > "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
                > de news:efExaO8JEH A.272@TK2MSFTNG P11.phx.gbl...[color=green]
                > > Hi,
                > >
                > > Yeah, but when you've got 'n' panels, it becomes harder. I'm going to[/color][/color]
                have[color=blue][color=green]
                > > to write a custom layout event handler I think.[/color]
                >
                > Perhaps, if you have a list of Panels, you can do a list, and loop
                >
                > while (elements_in_th e_list)
                > {
                > LTpanel.Locatio n = new Point(x * myPanel.ClientS ize.Width / N, x *
                > myPanel.ClientS ize.Height / N);
                > LTpanel.Width = myPanel.ClientS ize.Width / N;
                > LTpanel.Height = myPanel.ClientS ize.Height / N;
                > x++;
                > }
                >
                > And, if it's not only panels, you will have litte changes to do :o)
                >
                > Hope that help.
                >
                >[/color]


                Comment

                • Steve McLellan

                  #9
                  Re: Multiple panels with 'Fill' docking

                  Hi,

                  Yeah, I've done a system like that as a layout handler and it seems to work
                  fine. Thanks!

                  Steve

                  "Mathieu Chavoutier" <NoSpam@NoSpam. org> wrote in message
                  news:eQ6XL4DKEH A.1264@TK2MSFTN GP12.phx.gbl...[color=blue]
                  >
                  > "Steve McLellan" <sjm.NOSPAM AT fixerlabs DOT com> a écrit dans le message
                  > de news:efExaO8JEH A.272@TK2MSFTNG P11.phx.gbl...[color=green]
                  > > Hi,
                  > >
                  > > Yeah, but when you've got 'n' panels, it becomes harder. I'm going to[/color][/color]
                  have[color=blue][color=green]
                  > > to write a custom layout event handler I think.[/color]
                  >
                  > Perhaps, if you have a list of Panels, you can do a list, and loop
                  >
                  > while (elements_in_th e_list)
                  > {
                  > LTpanel.Locatio n = new Point(x * myPanel.ClientS ize.Width / N, x *
                  > myPanel.ClientS ize.Height / N);
                  > LTpanel.Width = myPanel.ClientS ize.Width / N;
                  > LTpanel.Height = myPanel.ClientS ize.Height / N;
                  > x++;
                  > }
                  >
                  > And, if it's not only panels, you will have litte changes to do :o)
                  >
                  > Hope that help.
                  >
                  >[/color]


                  Comment

                  Working...