Eto.Forms.TableLayout.AutoSized C# (CSharp) Method

AutoSized() public static method

Creates a table layout with an auto sized control.
Since controls fill an entire cell, you can use this method to create a layout that will ensure that the specified control gets its preferred size instead of stretching to fill the container. By default, extra space will be added to the right and bottom, unless centered is true, which will add equal space to the top/bottom, and left/right.
public static AutoSized ( Control control, Padding padding = null, bool centered = false ) : TableLayout
control Control Control to auto size.
padding Padding Padding around the control
centered bool If set to true center the control, otherwise control is upper left of the container.
return TableLayout
		public static TableLayout AutoSized(Control control, Padding? padding = null, bool centered = false)
		{
			if (centered)
			{
				var layout = new TableLayout(3, 3);
				layout.Padding = padding ?? Padding.Empty;
				layout.Spacing = Size.Empty;
				layout.SetColumnScale(0);
				layout.SetColumnScale(2);
				layout.SetRowScale(0);
				layout.SetRowScale(2);
				layout.Add(control, 1, 1);
				return layout;
			}
			else
			{
				var layout = new TableLayout(2, 2);
				layout.Padding = padding ?? Padding.Empty;
				layout.Spacing = Size.Empty;
				layout.Add(control, 0, 0);
				return layout;
			}
		}