/// <summary> /// Add button into proper table cell. /// </summary> private void AddItemToTabPage(ProductTabPageItem item, TableLayoutPanel tabPageLayout, int tabPageItemIndex) { int row; int column; AppModel.GetArrayEntryRowAndColumn(tabPageItemIndex, TAB_PAGE_LAYOUT_COLUMN_COUNT, out row, out column); tabPageLayout.Controls.Add(item.Button, column, row); item.Button.Dock = DockStyle.Fill; // Make button fill in table cell }
/// <summary> /// Initialize product tab page items. /// </summary> private void InitializeProductTabPageItems() { _items = new List <ProductTabPageItem>(); foreach (Product product in _orderForm.Model.Products) { ProductTabPageItem item = new ProductTabPageItem(_orderForm, product); _items.Add(item); } }
/// <summary> /// Add button into proper table cell. /// </summary> private void AddItemToTabPage(ProductTabPageItem item, TableLayoutPanel tabPageLayout, ref int tabPageItemCount) { int row; int column; GetRowAndColumn(tabPageItemCount, TAB_PAGE_LAYOUT_COLUMN_COUNT, out row, out column); tabPageLayout.Controls.Add(item.Button, column, row); item.Button.Dock = DockStyle.Fill; // Make button fill in table cell tabPageItemCount++; // Increment tab page item count }
/// <summary> /// Populate tab page with products of corresponding type. /// </summary> private void PopulateTabPageWithProducts(ref TabPage tabPage, int tabPageIndex) { TableLayoutPanel tabPageLayout = ( TableLayoutPanel )tabPage.Controls[TAB_PAGE_LAYOUT_NAME]; int tabPageItemCount = 0; foreach (Product product in _orderForm.Model.Products) { int productTabPageIndex = ( int )product.Type; if (productTabPageIndex != tabPageIndex) { continue; } ProductTabPageItem item = new ProductTabPageItem(_orderForm, product); _items.Add(item); // Make the item live with the form AddItemToTabPage(item, tabPageLayout, ref tabPageItemCount); } }