We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

child control size

I am trying to use the borderlayout to place child controls. 
Questions I have...
  1. How can I specify what percent of area each child can take, example, one child should take 20% and other 80% and should maintain when resizing the window.
  2. If I have more than 2 children in borderlayout, and want to place them in vertical order, child 1 takes 20%, child 2 takes 20% and child 3 takes remaining and should maintain when resizing the window.
What would be a better layout manager for my needs? 
Appreciate any samples.


1 Reply

JP Jagadeesan Pichaimuthu Syncfusion Team December 24, 2018 10:15 AM UTC

Hi Farooq Mohammed, 
 
Thank you for contacting Syncfusion support. 
  
We have checked your reported query “how to set the child controls size proportionally” and this can be achieved by SetConstraints method of GridBagLayout control. Also, we have prepared the sample which tries to meet your requirement. In this sample, we have set the Form as ContainerControl of GridBagLayout and adding child controls (like as Button1, Button2, Button3) in Form, then setting the child controls position in virtual grid using the parameters (grid position and cell span) of SetConstraints method. Please make use of the below code example and sample for your reference. 
 
// Need to initialize size for child controls 
this.gridBagLayout1.SetPreferredSize(this.button1, new System.Drawing.Size(0, 0)); 
this.gridBagLayout1.SetPreferredSize(this.button2, new System.Drawing.Size(0, 0)); 
this.gridBagLayout1.SetPreferredSize(this.button3, new System.Drawing.Size(0, 0)); 
 
//  
// borderLayout1 
//  
this.gridBagLayout1.ContainerControl = this; 
 
// Set Position of child controls in GridBagLayout  
this.gridBagLayout1.SetConstraints(this.button1, new Syncfusion.Windows.Forms.Tools.GridBagConstraints(0, 0, 1, 0, 0.2D, 1D, Syncfusion.Windows.Forms.Tools.AnchorTypes.Center, Syncfusion.Windows.Forms.Tools.FillType.Both, new Syncfusion.Windows.Forms.Tools.Insets(5, 5, 5, 5), 0, 0, false)); 
this.gridBagLayout1.SetConstraints(this.button2, new Syncfusion.Windows.Forms.Tools.GridBagConstraints(1, 0, 1, 0, 0.2D, 1D, Syncfusion.Windows.Forms.Tools.AnchorTypes.Center, Syncfusion.Windows.Forms.Tools.FillType.Both, new Syncfusion.Windows.Forms.Tools.Insets(5, 5, 5, 5), 0, 0, false)); 
this.gridBagLayout1.SetConstraints(this.button3, new Syncfusion.Windows.Forms.Tools.GridBagConstraints(2, 0, 3, 0, 0.6D, 1D, Syncfusion.Windows.Forms.Tools.AnchorTypes.Center, Syncfusion.Windows.Forms.Tools.FillType.Both, new Syncfusion.Windows.Forms.Tools.Insets(5, 5, 5, 5), 0, 0, false)); 
 
 
 
  
Please refer the below documentation for your further reference.  
  
  
Please try this above solution and let us know if it is helpful.  
    
Regards, 
Jagadeesan

Loader.
Live Chat Icon For mobile
Up arrow icon