SplitContainer
-
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?
-
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?
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...!!
-
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...!!
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!
-
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!
-
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...!!
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
-
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?
-
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?
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
-
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
Wow, cool control :) Thanks!