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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:13:50+00:00 2026-05-11T08:13:50+00:00

I have a small problem. I have a set of ComboBox’s that are bound

  • 0

I have a small problem. I have a set of ComboBox’s that are bound to lists which are associated with a set of dictionaries that provide int values for a math equation. I need to filter the result of cb_test_2 based on the selection of cb_test_1. I think I am close. What happens when I change the value in cb_test_1 it applies the correct list as a data bind to the ComboBox however, it doubles it, placing the list in the ComboBox twice. I cant seem to find what in my code is causing this. Please have a look. I welcome any help and or criticism.

namespace Break { partial class MainForm {     double x, y, z;           System.Collections.Generic.List<string> cable_size0;     System.Collections.Generic.List<string> cable_size1;     //System.Collections.Generic.List<string> cable_size2;     //System.Collections.Generic.List<string> cable_size3;     //List<string> cable_size4;     //List<string> cable_size5;     //List<string> cable_size6;     //List<string> cable_size7;     //List<string> cable_size8;     //List<string> cable_size9;     //List<string> cable_size10;             System.Collections.Generic.List<string> system_type_list;     System.Collections.Generic.List<string> amperage;      System.Collections.Generic.Dictionary<string, double> cable_dictionary_0;     System.Collections.Generic.Dictionary<string, double> cable_dictionary_1;      System.Collections.Generic.Dictionary<string, double> system_type;     System.Collections.Generic.Dictionary<string, double> amperage_dictionary;  private void MainFormLoad(object sender, EventArgs e)     {             //Each of the following lists populate the ComboBoxes             //to be selected on the main form.             amperage = new List<string>();             system_type_list = new List<string>();             //Filter             cable_size0 = new List<string>();             cable_size1 = new List<string>();             //cable_size2 = new List<string>();             //cable_size3 = new List<string>();             //cable_size4 = new List<string>();             //cable_size5 = new List<string>();             //cable_size6 = new List<string>();             //cable_size7 = new List<string>();             //cable_size8 = new List<string>();             //cable_size9 = new List<string>();             //cable_size10 = new List<string>();               system_type = new Dictionary<string, double>();             amperage_dictionary = new Dictionary<string, double>();             //Filter             cable_dictionary_0 = new Dictionary<string, double>();             cable_dictionary_1 = new Dictionary<string, double>();             //cable_dictionary_2 = new Dictionary<string, double>();             //cable_dictionary_3 = new Dictionary<string, double>();             //cable_dictionary_4 = new Dictionary<string, double>();             //cable_dictionary_5 = new Dictionary<string, double>();             //cable_dictionary_6 = new Dictionary<string, double>();             //cable_dictionary_7 = new Dictionary<string, double>();             //cable_dictionary_8 = new Dictionary<string, double>();             //cable_dictionary_9 = new Dictionary<string, double>();             //cable_dictionary_10 = new Dictionary<string, double>();              //             InitializeCurrentLoadCB();             InitializeSystemTypeCB();             //Cable size filter             if ((cb_test_1.SelectedIndex==0)||                 (cb_test_1.SelectedIndex==1)||                 (cb_test_1.SelectedIndex==2)||                 (cb_test_1.SelectedIndex==3))             {                 InitializeCableSizeCB0();                 InitializeCableLookup0();             }              //InitializeCableSizeCB2();             //InitializeCableSizeCB3();             //InitializeCableSizeCB4();             //InitializeCableSizeCB5();             //InitializeCableSizeCB6();             //InitializeCableSizeCB7();             //InitializeCableSizeCB8();             //InitializeCableSizeCB9();             //InitializeCableSizeCB10();               //---------------Dictionaries---------------------------------------------------------             InitializeSystemTypeLookup();             InitializeAmperageLookup();             //Cable Size Filter               //InitializeCableLookup2();             //InitializeCableLookup3();             //InitializeCableLookup4();             //InitializeCableLookup5();             //InitializeCableLookup6();             //InitializeCableLookup7();             //InitializeCableLookup8();             //InitializeCableLookup9();             //InitializeCableLookup10();      }      private void Cb_test_1SelectedIndexChanged(object sender, EventArgs e)     {         if ((cb_test_1.SelectedIndex==0)||                 (cb_test_1.SelectedIndex==1)||                 (cb_test_1.SelectedIndex==2)||                 (cb_test_1.SelectedIndex==3))             {                 InitializeCableSizeCB1();                                }     }       private void InitializeCurrentLoadCB()     {             //Amperage List, No Exclusions-----------------------------------------------------------              amperage.Add('Please Select Amperage');             amperage.Add('400');             amperage.Add('800');             amperage.Add('1000');             amperage.Add('1200');             amperage.Add('1600');             amperage.Add('2000');             amperage.Add('2500');             amperage.Add('3000');             amperage.Add('3200');             amperage.Add('4000');             amperage.Add('5000');             amperage.Add('6000');              cb_test_1.DataSource = amperage;             cb_test_1.SelectedIndex = 0;             cb_test_1.DropDownStyle = ComboBoxStyle.DropDownList;     }      private void InitializeCableSizeCB0()     {                        //Cable List, No Exclusions --------------------------------------------------------------             cable_size0.Add('Please Select Cable Size');             cable_size0.Add ('#1');             cable_size0.Add ('1/0');             cable_size0.Add ('2/0');             cable_size0.Add ('3/0');             cable_size0.Add ('4/0');             cable_size0.Add ('250');             cable_size0.Add ('300');             cable_size0.Add ('400');             cable_size0.Add ('500');             cable_size0.Add ('600');             cable_size0.Add ('700');             cable_size0.Add ('750');              cb_test_2.DataSource = cable_size0;             cb_test_2.SelectedIndex = 0;             cb_test_2.DropDownStyle = ComboBoxStyle.DropDownList;             //Initial DataBind for cable size ComboBox               }      private void InitializeCableSizeCB1()     {                        //Cable List, No Exclusions --------------------------------------------------------------             cable_size1.Add('Please Select Cable Size');             cable_size1.Add ('#1');             cable_size1.Add ('1/0');             cable_size1.Add ('2/0');             cable_size1.Add ('3/0');             cable_size1.Add ('4/0');             cable_size1.Add ('250');             cable_size1.Add ('300');             cable_size1.Add ('400');             cable_size1.Add ('500');              cb_test_2.DataSource = cable_size1;             cb_test_2.SelectedIndex = 0;             cb_test_2.DropDownStyle = ComboBoxStyle.DropDownList;             //Initial DataBind for cable size ComboBox               }      private void InitializeSystemTypeCB()     {             //System Type List                system_type_list.Add('Select System Type');             system_type_list.Add('3 Phase 3 Wire');             system_type_list.Add('3 Phase 4 Wire');              cb_test_3.DataSource = system_type_list;             cb_test_3.SelectedIndex = 0;             cb_test_3.DropDownStyle = ComboBoxStyle.DropDownList;             //Initial DataBind for cb_system type ComboBox                   }       private void Button1Click(object sender, System.EventArgs e)     {             if (!String.IsNullOrEmpty(cb_test_1.Text) &&            (!String.IsNullOrEmpty(cb_test_2.Text) &&             (!String.IsNullOrEmpty(cb_test_3.Text))))             {                    double a;                 if (cb_test_1.SelectedIndex != 0)                     {                         x = amperage_dictionary[amperage[cb_test_1.SelectedIndex]];                                      }                                                                         if (cb_test_2.SelectedIndex != 0)                     {                         y = cable_dictionary_0[cable_size0[cb_test_2.SelectedIndex]];                                        }                     if (cb_test_3.SelectedIndex != 0)                     {                         z = system_type[system_type_list[cb_test_3.SelectedIndex]];                     }                             a = ((x / y)*z);                 this.tb_1.Text = Math.Round(a,2).ToString();              }      }     private void InitializeSystemTypeLookup()     {         //System Type Dictionary          this.system_type.Add(this.system_type_list[0], 0);         this.system_type.Add(this.system_type_list[1], 3);         this.system_type.Add(this.system_type_list[2], 4);     }      private void InitializeAmperageLookup()     {         //Amperage Dictionary             this.amperage_dictionary.Add(this.amperage[0], 0);         this.amperage_dictionary.Add(this.amperage[1], 400);         this.amperage_dictionary.Add(this.amperage[2], 800);         this.amperage_dictionary.Add(this.amperage[3], 1000);         this.amperage_dictionary.Add(this.amperage[4], 1200);         this.amperage_dictionary.Add(this.amperage[5], 1600);         this.amperage_dictionary.Add(this.amperage[6], 2000);         this.amperage_dictionary.Add(this.amperage[7], 2500);         this.amperage_dictionary.Add(this.amperage[8], 3000);         this.amperage_dictionary.Add(this.amperage[9], 3200);         this.amperage_dictionary.Add(this.amperage[10], 4000);         this.amperage_dictionary.Add(this.amperage[11], 5000);         this.amperage_dictionary.Add(this.amperage[12], 6000);           }      private void InitializeCableLookup0()     {         //Cable Dictionary 0 used for cable quantity calculation         this.cable_dictionary_0.Add (this.cable_size0[0], 0);         this.cable_dictionary_0.Add (this.cable_size0[1], 130);         this.cable_dictionary_0.Add (this.cable_size0[2], 150);         this.cable_dictionary_0.Add (this.cable_size0[3], 175);         this.cable_dictionary_0.Add (this.cable_size0[4], 200);         this.cable_dictionary_0.Add (this.cable_size0[5], 230);         this.cable_dictionary_0.Add (this.cable_size0[6], 255);         this.cable_dictionary_0.Add (this.cable_size0[7], 285);         this.cable_dictionary_0.Add (this.cable_size0[8], 355);         this.cable_dictionary_0.Add (this.cable_size0[9], 380);         this.cable_dictionary_0.Add (this.cable_size0[10], 720);         this.cable_dictionary_0.Add (this.cable_size0[11], 475);     }  private void InitializeCableLookup1()     {         //Cable Dictionary 1 used for cable quantity calculation                     this.cable_dictionary_1.Add (this.cable_size1[0], 0);         this.cable_dictionary_1.Add (this.cable_size1[1], 130);         this.cable_dictionary_1.Add (this.cable_size1[2], 150);         this.cable_dictionary_1.Add (this.cable_size1[3], 175);         this.cable_dictionary_1.Add (this.cable_size1[4], 200);         this.cable_dictionary_1.Add (this.cable_size1[5], 230);         this.cable_dictionary_1.Add (this.cable_size1[6], 255);         this.cable_dictionary_1.Add (this.cable_size1[7], 285);         this.cable_dictionary_1.Add (this.cable_size1[8], 355);      }                      } 

}

  • 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. 2026-05-11T08:13:50+00:00Added an answer on May 11, 2026 at 8:13 am

    In InitializeCableSizeCB0(), make sure that you first remove any items from cable_size0, e.g:

    private void InitializeCableSizeCB0() {                            //Cable List, No Exclusions     cable_size0.Clear();     cable_size0.Add('Please Select Cable Size');     ... 

    Otherwise you will re-add the same items over and over again (every time InitializeCableSizeCB0() is called).

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

Sidebar

Related Questions

i have a small problem where my mandelbrot set is represented as a heightmap
I have a small problem which i can't seem to figure out. I tried
I have a small problem which i can't seem to solve myself. Look at
Have a small problem with LINQ queries. Basically I have two lists, filled with
I have given a diagram of my current small problem that I need help
I have small problem with my SQL code: UPDATE articles SET like=like+1 WHERE id=1
I have a small problem, which might me a stupid mistake on my side.
I have a small problem with JQuery .load that´s driving me nuts - I
I have a script that works great, but I have one small problem. I
have small problem, and would very much appreciate help :) I should convert byte

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.