April 27, 2012

C# ComboBox and ListBox


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

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

        private void Form1_Load(object sender, EventArgs e)
        {
         
        }

        private void button1_Click(object sender, EventArgs e)
        {

         
            if (comboBox1.SelectedIndex == -1)
                MessageBox.Show("Seçenek bulunuz");
            else
                listBox1.Items.Add(comboBox1.SelectedItem);
           }

        private void button2_Click(object sender, EventArgs e)
        {

            listBox1.Items.Remove(listBox1.SelectedItem);

        }

     
    }
}

No comments:

Post a Comment