9 Mayıs 2015 Cumartesi

C# Listboxlar Arası Veri Aktarma


Formumuza İki listbox 4 buton bir tane textbox ekliyoruz
 KODLAR;


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 WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int sira = 0;
        string[] isim = new string[15];
        int indexno;
        private void button1_Click(object sender, EventArgs e)
        {
            isim[sira] = textBox1.Text;
            sira++;
            listBox1.Items.Add(textBox1.Text);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            listBox1.Items.RemoveAt(indexno);
        }   
        private void listBox1_Click(object sender, EventArgs e)
        {
            indexno = listBox1.SelectedIndex;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
            listBox2.Items.Add(listBox1.Text);
           listBox1.Items.RemoveAt(indexno);
            
            }
            catch
            {
                MessageBox.Show("Hata");
            }
        }
        private void button6_Click(object sender, EventArgs e)
        {
            try
            {             
                 listBox1.Items.Add(listBox2.Text);
                listBox2.Items.RemoveAt(indexno);
            }
            catch
            {
                MessageBox.Show("Hata");
            }
        }

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