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

Horizontal() public static method

Creates a horizontal table layout with the specified cells.
Since table layouts are by default vertical by defining the rows and the cells for each row, it is verbose to create nested tables when you want a horizontal table. E.g. new TableLayout(new TableRow(...)). This method is used to easily create a single row table layout with a horizontal set of cells. E.g. TableLayout.Horizontal(...)
public static Horizontal ( ) : TableLayout
return TableLayout
		public static TableLayout Horizontal(params TableCell[] cells)
		{
			return new TableLayout(new TableRow(cells));
		}

Same methods

TableLayout::Horizontal ( int spacing ) : TableLayout

Usage Example

Ejemplo n.º 1
0
		void Create()
		{
			var table = new TableLayout { IsVisualControl = true };
			table.Spacing = new Size(Spacing, Spacing);

			bool filled = false;
			var expandItem = new StackLayoutItem { Expand = true };
			switch (Orientation)
			{
				case Orientation.Horizontal:
					var topRow = new TableRow();
					for (int i = 0; i < items.Count; i++)
					{
						var item = items[i] ?? expandItem;
						var align = GetVerticalAlign(item);
						var control = item.Control;
						filled |= item.Expand;
						var cell = new TableCell { ScaleWidth = item.Expand };
						switch (align)
						{
							case VerticalAlignment.Top:
								cell.Control = new TableLayout(control, null);
								break;
							case VerticalAlignment.Center:
								cell.Control = new TableLayout(null, control, null);
								break;
							case VerticalAlignment.Bottom:
								cell.Control = new TableLayout(null, control);
								break;
							case VerticalAlignment.Stretch:
								cell.Control = control;
								break;
							default:
								throw new ArgumentOutOfRangeException();
						}
						topRow.Cells.Add(cell);
					}
					if (!filled)
						topRow.Cells.Add(null);
					table.Rows.Add(topRow);
					break;
				case Orientation.Vertical:
					for (int i = 0; i < items.Count; i++)
					{
						var item = items[i] ?? expandItem;
						var align = GetHorizontalAlign(item);
						var control = item.Control;
						filled |= item.Expand;
						var vrow = new TableRow { ScaleHeight = item.Expand };
						switch (align)
						{
							case HorizontalAlignment.Left:
								vrow.Cells.Add(TableLayout.Horizontal(control, null));
								break;
							case HorizontalAlignment.Center:
								vrow.Cells.Add(TableLayout.Horizontal(null, control, null));
								break;
							case HorizontalAlignment.Right:
								vrow.Cells.Add(TableLayout.Horizontal(null, control));
								break;
							case HorizontalAlignment.Stretch:
								vrow.Cells.Add(control);
								break;
							default:
								throw new ArgumentOutOfRangeException();
						}
						table.Rows.Add(vrow);
					}
					if (!filled)
						table.Rows.Add(null);
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}
			Content = table;
			isCreated = true;
		}