Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Windows Forms
  4. SplitContainer

SplitContainer

Scheduled Pinned Locked Moved Windows Forms
question
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    ThetaClear
    wrote on last edited by
    #1

    Hi I have a SplitContainer with two panels. I'm adding controls dynamically through code to the first panel and it does it correctly - from left to right. Than I trying to add same controls BUT to the second panel but it adds them from the last location I ended adding controls in the first panel. Any idea how can I make the second add controls to the second panel from left to right? BTW, it also concern adding other controls - like adding a lable at the top of every panel and only AFTERWARS adding the contorols UNDER IT. Is there a way to move to the "next line" automatically or di I have to do it with a calculation?

    D D L 3 Replies Last reply
    0
    • T ThetaClear

      Hi I have a SplitContainer with two panels. I'm adding controls dynamically through code to the first panel and it does it correctly - from left to right. Than I trying to add same controls BUT to the second panel but it adds them from the last location I ended adding controls in the first panel. Any idea how can I make the second add controls to the second panel from left to right? BTW, it also concern adding other controls - like adding a lable at the top of every panel and only AFTERWARS adding the contorols UNDER IT. Is there a way to move to the "next line" automatically or di I have to do it with a calculation?

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      You should add controls this way:

      yourSplitContainer.Panel1.Controls.Add("Add control object here");
      yourSplitContainer.Panel2.Controls.Add("Add control object here");

      ThetaClear wrote:

      Is there a way to move to the "next line" automatically or di I have to do it with a calculation?

      You will have to perform calculations for this. Also, take care of proper Anchoring and Docking so that layout remains good on resizing the form. I personally prefer using TableLayoutPanel since it takes away a lot of pain that one needs to do while positioning dynamic controls. You can try using it if you wish.

      50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

      T 1 Reply Last reply
      0
      • D dan sh

        You should add controls this way:

        yourSplitContainer.Panel1.Controls.Add("Add control object here");
        yourSplitContainer.Panel2.Controls.Add("Add control object here");

        ThetaClear wrote:

        Is there a way to move to the "next line" automatically or di I have to do it with a calculation?

        You will have to perform calculations for this. Also, take care of proper Anchoring and Docking so that layout remains good on resizing the form. I personally prefer using TableLayoutPanel since it takes away a lot of pain that one needs to do while positioning dynamic controls. You can try using it if you wish.

        50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

        T Offline
        T Offline
        ThetaClear
        wrote on last edited by
        #3

        Thanks for your answer d@nish. The first code snippet is not very relevant to me because I need to separate two different types into two different areas. So after I iterate through the first type and finish adding it up:

        yourSplitContainer.Panel1.Controls.Add(object1);
        yourSplitContainer.Panel1.Controls.Add(object2);
        yourSplitContainer.Panel1.Controls.Add(object3);
        .
        .
        .

        I move on to the next type and ad it up

        yourSplitContainer.Panel2.Controls.Add(object1);
        yourSplitContainer.Panel2.Controls.Add(object2);
        yourSplitContainer.Panel3.Controls.Add(object3);
        .
        .
        .

        But as I said the locations of the second type are not placed from left to right. I'll try to use TableLayoutPanel - I have never used it before. Thanks!

        D 1 Reply Last reply
        0
        • T ThetaClear

          Thanks for your answer d@nish. The first code snippet is not very relevant to me because I need to separate two different types into two different areas. So after I iterate through the first type and finish adding it up:

          yourSplitContainer.Panel1.Controls.Add(object1);
          yourSplitContainer.Panel1.Controls.Add(object2);
          yourSplitContainer.Panel1.Controls.Add(object3);
          .
          .
          .

          I move on to the next type and ad it up

          yourSplitContainer.Panel2.Controls.Add(object1);
          yourSplitContainer.Panel2.Controls.Add(object2);
          yourSplitContainer.Panel3.Controls.Add(object3);
          .
          .
          .

          But as I said the locations of the second type are not placed from left to right. I'll try to use TableLayoutPanel - I have never used it before. Thanks!

          D Offline
          D Offline
          dan sh
          wrote on last edited by
          #4

          Are you adding same objects in both the panels? Are you setting the location of the objects properly?

          50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

          T 1 Reply Last reply
          0
          • D dan sh

            Are you adding same objects in both the panels? Are you setting the location of the objects properly?

            50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!

            T Offline
            T Offline
            ThetaClear
            wrote on last edited by
            #5

            The objects are same controls ListViews Well, no. I'm not setting this property at all. I thought there's some property to make the controls align left to right or something. The first panel's control's are being automatically added left to right, I didn't understand why this doesn't happen in the second panel.

            modified on Wednesday, December 30, 2009 5:32 AM

            1 Reply Last reply
            0
            • T ThetaClear

              Hi I have a SplitContainer with two panels. I'm adding controls dynamically through code to the first panel and it does it correctly - from left to right. Than I trying to add same controls BUT to the second panel but it adds them from the last location I ended adding controls in the first panel. Any idea how can I make the second add controls to the second panel from left to right? BTW, it also concern adding other controls - like adding a lable at the top of every panel and only AFTERWARS adding the contorols UNDER IT. Is there a way to move to the "next line" automatically or di I have to do it with a calculation?

              D Offline
              D Offline
              darkelv
              wrote on last edited by
              #6

              Use FlowLayoutPanel.

              1 Reply Last reply
              0
              • T ThetaClear

                Hi I have a SplitContainer with two panels. I'm adding controls dynamically through code to the first panel and it does it correctly - from left to right. Than I trying to add same controls BUT to the second panel but it adds them from the last location I ended adding controls in the first panel. Any idea how can I make the second add controls to the second panel from left to right? BTW, it also concern adding other controls - like adding a lable at the top of every panel and only AFTERWARS adding the contorols UNDER IT. Is there a way to move to the "next line" automatically or di I have to do it with a calculation?

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                add a fill-docked FlowLayoutPanel to each of the splitContainer's panels. :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                Merry Christmas and a Happy New Year to all.


                modified on Wednesday, December 30, 2009 7:51 AM

                T 1 Reply Last reply
                0
                • L Luc Pattyn

                  add a fill-docked FlowLayoutPanel to each of the splitContainer's panels. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]


                  Merry Christmas and a Happy New Year to all.


                  modified on Wednesday, December 30, 2009 7:51 AM

                  T Offline
                  T Offline
                  ThetaClear
                  wrote on last edited by
                  #8

                  Wow, cool control :) Thanks!

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups