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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

child control size

Thread ID:

Created:

Updated:

Platform:

Replies:

141619 Dec 21,2018 05:12 AM UTC Dec 24,2018 10:15 AM UTC WinForms 1
loading
Tags: BorderLayout
Farooq Mohammed
Asked On December 21, 2018 05:12 AM UTC

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.


Jagadeesan Pichaimuthu [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;