Working With Layouts
Layouts are used to display all the controls on the window in a required form
Layout will help us to keep the controls with same size though parent control size changes or screen resolution changes
Also layouts will help us to scale the size of the controls a/c to parent control size or a/c to screen resolution
Canvas Layout control
Canvas Layout is the fixed layout and the controls placed in canvas layout will not increase or decrease their size when parent control size changes.
Example With Canvas Controls
Create a new window with the name canvas layout
Crete canvas on window
Design the canvas
Create two buttons outside the canvas with the names b/n LTOR and btn RTOL respectively
Write the following code
Private void btn LTOR – click (object sender, Ronted Even Args e)
{
Canvas 1 Flow direction = flow direction. Left to right;
}
Private void btn RTOL_click()
{canvas1. Flow Direction= flow direction. Right To left;
}
When you run the form observe the controls by increasing or decreasing the size of the window, the controls placed with the canvas will not increase or decrease their size but the controls outside canvas will increase or decrease their sizes a/c to size of the control
Stock Panel
Stack panel layout is used to display the elements in the form of stack we can display the elements in vertical stack form or horizontal stack form
Properties
When set to
Vertical : The controls will be displayed or arranged in vertical stack from when set to
Horizontal: The controls will be organized in horizontal stack form