/// <summary> /// Method to perform an action when one of button of ProductBox is clicked /// </summary> private void clickBeli(object sender, EventArgs e) { Control c = (Control)sender; ProductBox parent = (ProductBox)c.Parent; parentHomePanel.Visible = false; parentDetailPanel.Visible = true; productDetail.Title = parent.Title; productDetail.Price = parent.Price; productDetail.Picture = parent.Picture; }
public MainMenu() { InitializeComponent(); Console.WriteLine("Hello"); #region Initialize products data productBoxes[0] = new ProductBox(); productBoxes[0].Title = "Supreme KW"; productBoxes[0].Kategori = "Baju"; productBoxes[0].Price = 100000; productBoxes[0].Picture = Resources.product0; productBoxes[1] = new ProductBox(); productBoxes[1].Title = "Playstation Series X"; productBoxes[1].Kategori = "Elektronik"; productBoxes[1].Price = 1000000; productBoxes[1].Picture = Resources.product1; productBoxes[2] = new ProductBox(); productBoxes[2].Title = "iPhone Galaxy S21"; productBoxes[2].Kategori = "Elektronik"; productBoxes[2].Price = 400000; productBoxes[2].Picture = Resources.product2; productBoxes[3] = new ProductBox(); productBoxes[3].Title = "Deus KW"; productBoxes[3].Kategori = "Baju"; productBoxes[3].Price = 200000; productBoxes[3].Picture = Resources.product3; productBoxes[4] = new ProductBox(); productBoxes[4].Title = "Gomu Gomu no Mi"; productBoxes[4].Kategori = "Makanan"; productBoxes[4].Price = 150000; productBoxes[4].Picture = Resources.product4; foreach (var product in productBoxes) { product.buttonBeli.Click += new EventHandler(clickBeli); } #endregion }