0% found this document useful (0 votes)
5 views2 pages

Combo Box

The document contains a C# Windows Forms application code for a simple menu management system. It allows users to add, delete, edit, and clear items from a list of desserts using a ComboBox and ListBox. The application includes basic error handling for user interactions.

Uploaded by

t7qnpvc6jd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Combo Box

The document contains a C# Windows Forms application code for a simple menu management system. It allows users to add, delete, edit, and clear items from a list of desserts using a ComboBox and ListBox. The application includes basic error handling for user interactions.

Uploaded by

t7qnpvc6jd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MEDYO_GETS_KO_NA
{
public partial class Form1 : Form
{
private int editindex = -1;
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)


{
comboBox1.Items.Add("COOKIES N CREAM");
comboBox1.Items.Add("CHOCO MOIST CAKE");
comboBox1.Items.Add("LAVA CAKE");
comboBox1.Items.Add("CHOCOLATE SUNDAE");
}

private void ADD_Click(object sender, EventArgs e)


{
if (comboBox1.SelectedItem != null)
{
listBox1.Items.Add(comboBox1.SelectedItem);
}
else
{
MessageBox.Show("Please select an item from Combobox.");
}
}

private void DELETE_Click(object sender, EventArgs e)


{
if (listBox1.SelectedItem != null)
{
listBox1.Items.Remove(listBox1.SelectedItem);
}
else
{
MessageBox.Show("Please select an item to delete from listbox");
}
}

private void CLEARALL_Click(object sender, EventArgs e)


{
listBox1.Items.Clear();
}

private void EDIT_Click(object sender, EventArgs e)


{
if (listBox1.SelectedItem != null)
{
editindex = listBox1.SelectedIndex;
listBox1.SelectedItem = comboBox1.SelectedItem;
}
else
{
MessageBox.Show("Please select an item to edit from the ListBox.");
}
}

private void EDITSAVE_Click(object sender, EventArgs e)


{
if (editindex != -1 && comboBox1.SelectedItem != null)
{
listBox1.Items[editindex] = comboBox1.SelectedItem;
editindex = -1;
}
else
{
MessageBox.Show("No item is currently being edited or no item is selected
in the ComboBox.");
}
}

private void EXIT_Click(object sender, EventArgs e)


{
this.Close();
}
}
}

You might also like