Shopping Cart Visual Program in C Sharp

By | August 26, 2023

Shopping Cart Visual Program in C Sharp – This is a Windows forms application in C Sharp. Design a Shopping cart using List box to ass items with prices. Add a text box to enter new items (add cart) in list box 1. Add three buttons , first button ‘Add Item to Cart’ will add item in text box to list box 1. The second button is ‘Remove selected Item from Cart list box 1. The third button is to ‘Display Selected Items from Cart – List box 1 into another list box 2.

List Box <yoastmark class=

Source Code of List Box Shopping Cart


using System;

using System.Windows.Forms;

namespace ListBoxShoppingCart
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {

            
            foreach (string sitem in listBox1.SelectedItems)
            {
                listBox2.Items.Add(sitem);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Add(textBox1.Text);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Remove(listBox1.Text);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            listBox2.Items.Clear();
        }
    }
}

Output

List box Shopping Cart Visual Program in C Sharp

Visual Programming using C sharp – List box Shopping Cart

Loading

Leave a Reply

Your email address will not be published. Required fields are marked *