Ejemplo n.º 1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            ProductList.SelectedIndex = -1;
            Product p = new Product("---", 0);

            list.Add(p);
            ProductList.SelectedIndex = ProductList.Items.IndexOf(p);
            EdName.Focus();
            EdName.SelectAll();
        }
Ejemplo n.º 2
0
        private void BtnRemove_Click(object sender, EventArgs e)
        {
            int     pos = ProductList.SelectedIndex;
            Product p   = (Product)ProductList.SelectedValue;

            list.Remove(p);
            ProductList.SelectedIndex = Math.Min(pos, ProductList.Items.Count - 1);
            if (ProductList.SelectedIndex < 0)
            {
                EdName.Clear();
                EdPrice.Clear();
            }
            ProductList.Focus();
        }