-
-
Save blahlicus/f6a01a0c692ff5ae0772072297040442 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
partial class FilledForm : Form | |
{ | |
void InitializeComponent() | |
{ | |
Title = "Test Form"; | |
ClientSize = new Size(1920, 1080); | |
var tlMain = new TableLayout(); | |
var trRow = new TableRow(); | |
trRow.ScaleHeight = true; | |
tlMain.Rows.Add(trRow); | |
var tcCell = new TableCell(); | |
tcCell.ScaleWidth = true; | |
trRow.Cells.Add(tcCell); | |
var btnMain = new Button(); | |
btnMain.Text = "This button fills the entire form"; | |
trCell.Control = btnMain; | |
Content = tlMain; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
partial class HalfFilledForm : Form | |
{ | |
void InitializeComponent() | |
{ | |
Title = "Test Form"; | |
ClientSize = new Size(1920, 1080); | |
var tlMain = new TableLayout(); | |
var trRow = new TableRow(); | |
trRow.ScaleHeight = true; | |
tlMain.Rows.Add(trRow); | |
var tcCell = new TableCell(); | |
tcCell.ScaleWidth = true; | |
trRow.Cells.Add(tcCell); | |
var btnMain = new Button(); | |
btnMain.Text = "This button occupies the left half of the form"; | |
tcCell.Control = btnMain; | |
// adding another cell to the table row and setting both cells' ScaleWidth property to true evenly divides screen spaces between the two of them | |
// you may add more cells in front and behind of your "main" element as spacers. | |
var tcSpacer = new TableCell(); | |
tcSpacer.ScaleWidth = true; | |
tcSpacer.Control = null; // <-- set the content of a cell as null and set ScaleWidth as true to create empty spaces with TableLayout | |
trRow.Cells.Add(tcSpacer); | |
Content = tlMain; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment