C# listbox ekleme silme kayıt sayısı bulma işlemleri - Bilişim Konuları

C# listbox ekleme silme kayıt sayısı bulma işlemleri

C# listbox ekleme silme kayıt sayısı bulma işlemleri. İki tane listbox ile eleman ekleme, silme, bir listboxtan diğer listboxa taşıma işlemlerinin nasıl yapıldığını anlatan güzel bir örnek

Program 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 listbox3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            listBox1.Items.Add(textBox1.Text);
            label3.Text = "Liste1 El.Sa:" + listBox1.Items.Count.ToString();
            label4.Text = "Liste2 El.Sa:" + listBox2.Items.Count.ToString();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            listBox2.Items.Add(textBox2.Text);
            label3.Text = "Liste1 El.Sa:" + listBox1.Items.Count.ToString();
            label4.Text = "Liste2 El.Sa:" + listBox2.Items.Count.ToString();
        }

        private void button6_Click(object sender, EventArgs e)
        {
            listBox2.Items.Add(listBox1.SelectedItem);
            listBox1.Items.Remove(listBox1.SelectedItem);
            label3.Text = "Liste1 El.Sa:"+ listBox1.Items.Count.ToString();
            label4.Text = "Liste2 El.Sa:" + listBox2.Items.Count.ToString();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            listBox1.Items.Add(listBox2.SelectedItem);
            listBox2.Items.Remove(listBox2.SelectedItem);
            label3.Text = "Liste1 El.Sa:" + listBox1.Items.Count.ToString();
            label4.Text = "Liste2 El.Sa:" + listBox2.Items.Count.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            listBox1.Items.Remove(listBox1.SelectedItem);
            label3.Text = "Liste1 El.Sa:" + listBox1.Items.Count.ToString();
            label4.Text = "Liste2 El.Sa:" + listBox2.Items.Count.ToString();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            listBox2.Items.Remove(listBox2.SelectedItem);
            label3.Text = "Liste1 El.Sa:" + listBox1.Items.Count.ToString();
            label4.Text = "Liste2 El.Sa:" + listBox2.Items.Count.ToString();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            label1.Text = listBox1.SelectedIndex.ToString();
        }

        private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            label2.Text = listBox2.SelectedIndex.ToString();
        }
    }
}

Ekran Görüntüleri



Bu Yazıya Tepkin Nedir?
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0
+1
0

Yorum Yap