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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:19:50+00:00 2026-05-25T22:19:50+00:00

Does anyone know of a nice, usable class that everyone on here could benefit

  • 0

Does anyone know of a nice, usable class that everyone on here could benefit from to use in populating the ComboBox controls on a form for the Country and State fields?

I hate having to reinvent the wheel every time, and someone has probably done a very nice piece of work somewhere.

Bonus points if the existing class can return a list of State options whenever the Country is selected!

I’m currently developing this for a Windows Form (non-web application), and this project can’t pull from a website.

  • 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-25T22:19:50+00:00Added an answer on May 25, 2026 at 10:19 pm

    OK, so I made one.

    I built it nice and generic, so anyone should be able to use it

    There is a class at the bottom called US_States that is used as a container to store the State Name and State Abbreviation.

    static class StateArray {
    
      static List<US_State> states;
    
      static StateArray() {
        states = new List<US_State>(50);
        states.Add(new US_State("AL", "Alabama"));
        states.Add(new US_State("AK", "Alaska"));
        states.Add(new US_State("AZ", "Arizona"));
        states.Add(new US_State("AR", "Arkansas"));
        states.Add(new US_State("CA", "California"));
        states.Add(new US_State("CO", "Colorado"));
        states.Add(new US_State("CT", "Connecticut"));
        states.Add(new US_State("DE", "Delaware"));
        states.Add(new US_State("DC", "District Of Columbia"));
        states.Add(new US_State("FL", "Florida"));
        states.Add(new US_State("GA", "Georgia"));
        states.Add(new US_State("HI", "Hawaii"));
        states.Add(new US_State("ID", "Idaho"));
        states.Add(new US_State("IL", "Illinois"));
        states.Add(new US_State("IN", "Indiana"));
        states.Add(new US_State("IA", "Iowa"));
        states.Add(new US_State("KS", "Kansas"));
        states.Add(new US_State("KY", "Kentucky"));
        states.Add(new US_State("LA", "Louisiana"));
        states.Add(new US_State("ME", "Maine"));
        states.Add(new US_State("MD", "Maryland"));
        states.Add(new US_State("MA", "Massachusetts"));
        states.Add(new US_State("MI", "Michigan"));
        states.Add(new US_State("MN", "Minnesota"));
        states.Add(new US_State("MS", "Mississippi"));
        states.Add(new US_State("MO", "Missouri"));
        states.Add(new US_State("MT", "Montana"));
        states.Add(new US_State("NE", "Nebraska"));
        states.Add(new US_State("NV", "Nevada"));
        states.Add(new US_State("NH", "New Hampshire"));
        states.Add(new US_State("NJ", "New Jersey"));
        states.Add(new US_State("NM", "New Mexico"));
        states.Add(new US_State("NY", "New York"));
        states.Add(new US_State("NC", "North Carolina"));
        states.Add(new US_State("ND", "North Dakota"));
        states.Add(new US_State("OH", "Ohio"));
        states.Add(new US_State("OK", "Oklahoma"));
        states.Add(new US_State("OR", "Oregon"));
        states.Add(new US_State("PA", "Pennsylvania"));
        states.Add(new US_State("RI", "Rhode Island"));
        states.Add(new US_State("SC", "South Carolina"));
        states.Add(new US_State("SD", "South Dakota"));
        states.Add(new US_State("TN", "Tennessee"));
        states.Add(new US_State("TX", "Texas"));
        states.Add(new US_State("UT", "Utah"));
        states.Add(new US_State("VT", "Vermont"));
        states.Add(new US_State("VA", "Virginia"));
        states.Add(new US_State("WA", "Washington"));
        states.Add(new US_State("WV", "West Virginia"));
        states.Add(new US_State("WI", "Wisconsin"));
        states.Add(new US_State("WY", "Wyoming"));
      }
    
      public static string[] Abbreviations() {
        List<string> abbrevList = new List<string>(states.Count);
        foreach (var state in states) {
          abbrevList.Add(state.Abbreviations);
        }
        return abbrevList.ToArray();
      }
    
      public static string[] Names() {
        List<string> nameList = new List<string>(states.Count);
        foreach (var state in states) {
          nameList.Add(state.Name);
        }
        return nameList.ToArray();
      }
    
      public static US_State[] States() {
        return states.ToArray();
      }
    
    }
    
    class US_State {
    
      public US_State() {
        Name = null;
        Abbreviations = null;
      }
    
      public US_State(string ab, string name) {
        Name = name;
        Abbreviations = ab;
      }
    
      public string Name { get; set; }
    
      public string Abbreviations { get; set; }
    
      public override string ToString() {
        return string.Format("{0} - {1}", Abbreviations, Name);
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know of a nice way to: produce XSD documents from an SQL
Does anyone know of a good TreeView for the web that is nice looking,
Does anyone know a way to produce a nice publication quality LaTeX table from
Does anyone know of any (free) tools that will convert an old Delhi 5
Does anyone know how to get the operating system information from a microsoft sql
Io is a nice cross-platform prototype-based object-oriented language. Does anyone know of any GUI
Does anyone know of a library or bit of code that converts British English
Does anyone know of any software that can be used to create Agile User
Does anyone know if it's possible to use the bits and pieces of Windows
Does anyone know of a neat way in java or any packages that will

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.