C# Archives - Tech Insights https://reactconf.org/category/add-listitem-from-one-listbox-to-another-listbox-with-preventing-duplicate-in-c/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Mon, 05 Jan 2015 17:30:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 C# Archives - Tech Insights https://reactconf.org/category/add-listitem-from-one-listbox-to-another-listbox-with-preventing-duplicate-in-c/ 32 32 230003556 Add Listitem from one listbox to another listbox with preventing duplicate in c# https://reactconf.org/add-listitem-from-one-listbox-to-another/ https://reactconf.org/add-listitem-from-one-listbox-to-another/#respond Mon, 05 Jan 2015 17:30:00 +0000 https://reactconf.org/add-listitem-from-one-listbox-to-another/ In this article I’m going to explain how to add listitem from one listbox to another listbox with preventing duplicate.      usingSystem; usingSystem.Collections.Generic; usingSystem.ComponentModel; usingSystem.Data; usingSystem.Drawing; usingSystem.Linq; usingSystem.Text; usingSystem.Windows.Forms; namespaceAddlistitemOneListboxtoAnotherListbox …

The post Add Listitem from one listbox to another listbox with preventing duplicate in c# appeared first on Tech Insights.

]]>
In this article I’m going to explain how to add listitem from one listbox to another listbox with preventing duplicate.
    
usingSystem;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.Windows.Forms;
namespaceAddlistitemOneListboxtoAnotherListbox
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private voidForm1_Load(object sender, EventArgs e)
        {
            listBox1.Items.Add(“AAA”);
            listBox1.Items.Add(“BBB”);
            listBox1.Items.Add(“CCC”);
            listBox1.Items.Add(“DDD”);
            listBox1.Items.Add(“EEE”);
        }
        private voidbutton1_Click(object sender, EventArgs e)
        {
           
            if (listBox1.SelectedIndex>-1 )
            {
                string str = listBox1.GetItemText(listBox1.SelectedItem);
                int idx = listBox2.FindString(str, -1);
  
                   if (idx!=-1)
                   {
                       MessageBox.Show(“Found the item – “ + str);
                   }
                   else
                   {
                 
                   listBox2.Items.Add(listBox1.SelectedItem);
              }
            }
        }
      }

}




The post Add Listitem from one listbox to another listbox with preventing duplicate in c# appeared first on Tech Insights.

]]>
https://reactconf.org/add-listitem-from-one-listbox-to-another/feed/ 0 2234