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 4570210
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:19:45+00:00 2026-05-21T19:19:45+00:00

I have three listBoxes: listBox1 have the following items: Fruit and vegetable. listBox2 have

  • 0

I have three listBoxes:

listBox1 have the following items: Fruit and vegetable.

listBox2 have the following items: Orange, Apple, cucumber and Tomato.

listBox3 have the following items: Red, Green, Yellow and Orange.

And i want to do like this, if i select Fruit in listBox1 i only want to show Orange and Apple in listBox2 and if i select Apple in listBox2 i want to show Red, Green and Yellow for example.

And if nothing is selected in listBox1 then listBox2 and 3 shall be empty and if nothing is selected in listBox2 then listBox3 shall be empty.

And is there any good way to make a select/deselect method?

Thanks!

  • 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-05-21T19:19:46+00:00Added an answer on May 21, 2026 at 7:19 pm

    You can try something like this, for easy understanding divide the functionality into functions. I designed this code using win forms however you can apply same code on List boxes as well.

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch(comboBox1.SelectedItem.ToString())
            {
                case "Fruit":
                    FruitSelected();
                    break;
                case "Vegetables":
                    VegetableSelected();
                    break;
                default:
                    NoneSelected();
                    break;
            }
        }
        private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Similar code as above
        }
        protected void FruitSelected()
        {
            comboBox2.Items.Clear();
            comboBox2.Items.Add("Orange");
            comboBox2.Items.Add("Apple");
        }
        protected void VegetableSelected()
        {
            comboBox2.Items.Clear();
            comboBox2.Items.Add("Tomato");
            comboBox2.Items.Add("Cucumber");
        }
        protected void NoneSelected()
        {
            comboBox2.Items.Clear();
            comboBox3.Items.Clear();
        }
    }
    

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three colors in an array, array('blue', 'red', 'green') , and in my
At present I have two WPF listboxes imitating the following functionality (source: psu.edu )
I want to display a listbox containng list items, I have the following template
I have one ListBox which has three Items in it. And also has one
My environment is windows phone 7.1. I have the following code: <ListBox ItemsSource="{Binding Path=Items}">
I have written following method with three sql queries in order to update a
I have a ListBox that can contain hundreds of items. I've added the following
Have three classes User, Group and Field. Many to many relationship on User /
Have three divs in a container that I want to float over a large
I have three tables A: A.pID primary key, A.Name nvarchar(250) B: B.pID primary key,

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.