Click here to Skip to main content
15,748,749 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have one combobox having item1, item2, item3, item4, item5, item6.......item10

i have a checked list box consist of 20 functions

each combobox item has different functions

when i click on combobox items then all the functions belonging to that item will

be set as checked

can u help me how to do this

You will need to group your functions in an array or a list. On combobox selected index change event you need to match the array/list with the item choosen in combobox. Then run a foreach loop and match all the items with the one in array/list and set them to checked. If you didn't get my point, ask again in comments.
Share this answer
I assume ,

1) It is a Windows application
2) You have a ComboBox with 10items.
3) You have CheckedListBox with 20items and
4) The business is, Every item selection from the ComboBox will check associate CheckedListBox items, for example,

Item1 =>{ Option1, Option2 }
Item2 =>{ Option1, Option2,Option4 } etc.

Following code might help you,

namespace Gui_ComboBox
    using System.Linq;
    using System.Windows.Forms;
    public partial class frmMain : Form

        private Dictionary<string, string> StrategyOfSelection = new Dictionary<string, string>()
            // So On...
        public frmMain()

        private void cbSelector_SelectedIndexChanged(object sender, EventArgs e)
            if (StrategyOfSelection.Keys.Contains(cbSelector.SelectedItem.ToString()))
                string[] optionsToSelect = StrategyOfSelection[cbSelector.SelectedItem.ToString()].Split(new char[] { ',' });
                foreach (string item in optionsToSelect)
                    clbOptions.SetItemChecked(clbOptions.FindStringExact(item), true);

        private void UnCheckedAll()
            for (int i = 0; i < this.clbOptions.Items.Count; ++i)
                clbOptions.SetItemChecked(i, false);

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900