Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8130481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:43:36+00:00 2026-06-06T08:43:36+00:00

I need to add checked items from one checklistbox to another. I should not

  • 0

I need to add checked items from one checklistbox to another.

I should not add an item more than once into the second checklistbox.

The design has two checklistboxes and the following buttons: >,>>,<,<<

I have tried the code below but not able to get any display.Please let me know where i am going wrong:

namespace TwoListBox
{
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }

        public delegate void OneArrowForwardClickHandler();

        public event OneArrowForwardClickHandler OneArrowForward;

        private void button1_Click(object sender, EventArgs e)
        {
            OneArrowForward += new OneArrowForwardClickHandler(OneForward);
        }

        public void OneForward()
        {
            foreach (Object cs in checkedListBox1.CheckedItems)
            {
                if (!checkedListBox2.Items.Contains(cs))
                    checkedListBox2.Items.Add(cs.ToString());
                else
                {
                    MessageBox.Show("Item is already added");
                    continue;
                }
            }
        }

        public delegate void TwoArrowForwardClickHandler();

        public event TwoArrowForwardClickHandler TwoArrowForward;

        private void button2_Click(object sender, EventArgs e)
        {
            TwoArrowForward += new TwoArrowForwardClickHandler(TwoForward);
        }

        public void TwoForward()
        {
            foreach (Object cs in checkedListBox1.Items)
            {
                if (!checkedListBox2.Items.Contains(cs))
                    checkedListBox2.Items.Add(cs.ToString());
                else
                    MessageBox.Show("Items were already added");
            }
        }

        public delegate void OneArrowBackwardClickHandler();

        public event OneArrowBackwardClickHandler OneArrowBackward;

        private void button3_Click(object sender, EventArgs e)
        {
            OneArrowBackward += new OneArrowBackwardClickHandler(OneBackward);

        }

        public void OneBackward()
        {
            foreach (Object cs in checkedListBox1.CheckedItems)
            {
                checkedListBox2.Items.Remove(cs);
            }
        }

        public delegate void TwoArrowBackwardClickHandler();

        public event TwoArrowBackwardClickHandler TwoArrowBackward; 

        private void button4_Click(object sender, EventArgs e)
        {
            TwoArrowBackward +=new TwoArrowBackwardClickHandler(TwoBackward);
        }

        public void TwoBackward()
        {
            foreach (Object cs in checkedListBox1.Items)
            {
                checkedListBox2.Items.Remove(cs);
            }

        }

        private void button5_Click(object sender, EventArgs e)
        {
            string s = "The selected items are:";
            for (int i = 0; i < checkedListBox2.Items.Count - 1; i++)
            {
                s += checkedListBox2.CheckedItems[i].ToString() + "\n";
            }
            MessageBox.Show(s);
        }

    }
}

Note: > means add checked items ,>> means add all items,< means delete selected items,<< means delete all items

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T08:43:38+00:00Added an answer on June 6, 2026 at 8:43 am

    In your button click events your only adding an event handler to the events. Have you tried calling the function directly?

    Instead of creating an event handler, call each of the functions similar to how you would call OneForward() below from your button1’s click event:

        private void button1_Click(object sender, EventArgs e)
        {
            OneForward();
        }
    

    Response to comment

    If you mean that you want to inform the parent that your button was clicked and the OneForward had completed you can the following line at the end of your OneForward function:

    OneArrowForward(this, new EventArgs());
    

    But if you want to call OneForward from the parent, you will have to make it public then from the parent you would simply call:

    myUserControlInstance.OneForward();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add values received from MySQL into an array (PHP). Here is
I had to add another table into my database and now I need to
I need add a new user group for mediawiki. The new group has more
I received some compiled classes that I need to add to a project. One
can i add one dictionary object to another dictionary. I mean i am having
need to add a 2nd css stylesheet to a page. do i add a
I need to add an invite users functionality to my social networking application so
I need to add CRRedist2008_x86.msi to my deployment project as it is a requirement
I need to add css height to each page dynamically with jQuery. So far
I need to add a new column to a MS SQL 2005 database with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.