Print Friendly and PDF
Using ComboBoxes) Write an app that displays the names of 15 states in a ComboBox. When an item is selected from the ComboBox, remove it.
Using ComboBoxes) Write an app that displays the names of 15 states in a ComboBox. When an item is selected from the ComboBox, remove it.
Combobox

Solution:

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 Q2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
         
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                comboBox1.Items.Remove(comboBox1.SelectedItem);
            }
            if (comboBox1.SelectedIndex == 1)
            {
                comboBox1.Items.Remove(comboBox1.SelectedItem);
            }
            if (comboBox1.SelectedIndex == 2)
            {
                comboBox1.Items.Remove(comboBox1.SelectedItem);
            }
        }
    }
}

zubairsaif

Zubair saif

A passionate writer who loves to write on new technology and programming

Post A Comment:

0 comments: