SUNIL GUTTA

SUNIL GUTTA

  • NA
  • 1k
  • 393.9k

3 level Cascading combo-boxes ?

Feb 11 2013 6:49 AM
Hi friends

Well here i am looking to create a 3-level combo box cascading filter like in example Country--> State --> City :
Upon selection in countries in combo-box1 respective states should display in combo-box2 the after upon state selection cities should get displayed under combo-box3 . (like drill down).


My work : I used arrays to store states of respective countries  & the after i am able to display states in combo-box2 upon country selection in combo-box1 .
Well then after , on selection of req'd state i was unable to develop the logic to get what i req'd i.e 



I have created country list into combobox-1 (india,usa,australia) in collection & binded event proc of combobox-1 with combobox-2
   
    string[] s1 = { "AP","UP","Delhi"};
        string[] s2 = { "chicago","Dallas"};
        string[] s3 = { "melborne","sydney"};
        string[] s4 = { "AP1", "Ap2" };
        string[] s5 = { "UP1", "UP2" };
        string[] s6 = { "Delhi1", "delhi2" };
        string[] s7 = { "c1", "C2" };
        string[] s8 = { "Dallas1" };
        string[] s9 = { "M1","M2" };
        string[] s10 = { "S1","S2" };
private void Form11_Load(object sender, EventArgs e)
        {
            comboBox2.Items.Clear();
            switch (comboBox1.SelectedIndex)
            {
                case 0: comboBox2.Items.AddRange(s1);
                    break;
                case 1: comboBox2.Items.AddRange(s2);
                    break;
                case 2: comboBox2.Items.AddRange(s3);
                    break;
               
            }


So anyone can help me with this bizarre situation :( Need logic to implement this in c#.net windows forms


Thanks in advance 



Answers (4)