private void frmProducts_Load(object sender, EventArgs e) { // wire the event to the method that handles the event products.Changed += new ProductList.ChangeHandler(PrintToConsole); // add products to the product list products.Add("BJWN", "Beginning Java with NetBeans", 57.50m); products.Add("CS15", "C# 2015", 56.5m); // call the delegate and pass the required argument myDelegate(products); }
private void btnAdd_Click(object sender, EventArgs e) { frmNewProduct newProductForm = new frmNewProduct(); Product product = newProductForm.GetNewProduct(); if (product != null) { products.Add(product); products.Save(); FillProductListBox(); } }