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
public partial class State
{
public string Name { get; set; }
public string Abbreviations { get; set; }
}
///
/// Return a static list of all U.S. states
///
///
public IEnumerable ListOfStates()
{
var states = CreateStateList();
return states.ToList();
}
private static IList CreateStateList()
{
List states = new List();
states.Add(new State() { Abbreviations = "AL", Name = "Alabama" });
states.Add(new State() { Abbreviations = "AK", Name = "Alaska" });
states.Add(new State() { Abbreviations = "AR", Name = "Arkansas" });
states.Add(new State() { Abbreviations = "AZ", Name = "Arizona" });
states.Add(new State() { Abbreviations = "CA", Name = "California" });
states.Add(new State() { Abbreviations = "CO", Name = "Colorado" });
states.Add(new State() { Abbreviations = "CT", Name = "Connecticut" });
states.Add(new State() { Abbreviations = "DC", Name = "District of Columbia" });
states.Add(new State() { Abbreviations = "DE", Name = "Delaware" });
states.Add(new State() { Abbreviations = "FL", Name = "Florida" });
states.Add(new State() { Abbreviations = "GA", Name = "Georgia" });
states.Add(new State() { Abbreviations = "HI", Name = "Hawaii" });
states.Add(new State() { Abbreviations = "ID", Name = "Idaho" });
states.Add(new State() { Abbreviations = "IL", Name = "Illinois" });
states.Add(new State() { Abbreviations = "IN", Name = "Indiana" });
states.Add(new State() { Abbreviations = "IA", Name = "Iowa" });
states.Add(new State() { Abbreviations = "KS", Name = "Kansas" });
states.Add(new State() { Abbreviations = "KY", Name = "Kentucky" });
states.Add(new State() { Abbreviations = "LA", Name = "Louisiana" });
states.Add(new State() { Abbreviations = "ME", Name = "Maine" });
states.Add(new State() { Abbreviations = "MD", Name = "Maryland" });
states.Add(new State() { Abbreviations = "MA", Name = "Massachusetts" });
states.Add(new State() { Abbreviations = "MI", Name = "Michigan" });
states.Add(new State() { Abbreviations = "MN", Name = "Minnesota" });
states.Add(new State() { Abbreviations = "MS", Name = "Mississippi" });
states.Add(new State() { Abbreviations = "MO", Name = "Missouri" });
states.Add(new State() { Abbreviations = "MT", Name = "Montana" });
states.Add(new State() { Abbreviations = "NE", Name = "Nebraska" });
states.Add(new State() { Abbreviations = "NH", Name = "New Hampshire" });
states.Add(new State() { Abbreviations = "NJ", Name = "New Jersey" });
states.Add(new State() { Abbreviations = "NM", Name = "New Mexico" });
states.Add(new State() { Abbreviations = "NY", Name = "New York" });
states.Add(new State() { Abbreviations = "NC", Name = "North Carolina" });
states.Add(new State() { Abbreviations = "NV", Name = "Nevada" });
states.Add(new State() { Abbreviations = "ND", Name = "North Dakota" });
states.Add(new State() { Abbreviations = "OH", Name = "Ohio" });
states.Add(new State() { Abbreviations = "OK", Name = "Oklahoma" });
states.Add(new State() { Abbreviations = "OR", Name = "Oregon" });
states.Add(new State() { Abbreviations = "PA", Name = "Pennsylvania" });
states.Add(new State() { Abbreviations = "RI", Name = "Rhode Island" });
states.Add(new State() { Abbreviations = "SC", Name = "South Carolina" });
states.Add(new State() { Abbreviations = "SD", Name = "South Dakota" });
states.Add(new State() { Abbreviations = "TN", Name = "Tennessee" });
states.Add(new State() { Abbreviations = "TX", Name = "Texas" });
states.Add(new State() { Abbreviations = "UT", Name = "Utah" });
states.Add(new State() { Abbreviations = "VT", Name = "Vermont" });
states.Add(new State() { Abbreviations = "VA", Name = "Virginia" });
states.Add(new State() { Abbreviations = "WA", Name = "Washington" });
states.Add(new State() { Abbreviations = "WV", Name = "West Virginia" });
states.Add(new State() { Abbreviations = "WI", Name = "Wisconsin" });
states.Add(new State() { Abbreviations = "WY", Name = "Wyoming" });
return states.ToList();
}
VB.NET
Public Shared Function CreateStateList() As IList(Of State)
Dim states As New List(Of State)()
states.Add(New State() With {.Abbreviation = "AL", .Name = "Alabama"})
states.Add(New State() With {.Abbreviation = "AK", .Name = "Alaska"})
states.Add(New State() With {.Abbreviation = "AR", .Name = "Arkansas"})
states.Add(New State() With {.Abbreviation = "AZ", .Name = "Arizona"})
states.Add(New State() With {.Abbreviation = "CA", .Name = "California"})
states.Add(New State() With {.Abbreviation = "CO", .Name = "Colorado"})
states.Add(New State() With {.Abbreviation = "CT", .Name = "Connecticut"})
states.Add(New State() With {.Abbreviation = "DC", .Name = "District of Columbia"})
states.Add(New State() With {.Abbreviation = "DE", .Name = "Delaware"})
states.Add(New State() With {.Abbreviation = "FL", .Name = "Florida"})
states.Add(New State() With {.Abbreviation = "GA", .Name = "Georgia"})
states.Add(New State() With {.Abbreviation = "HI", .Name = "Hawaii"})
states.Add(New State() With {.Abbreviation = "ID", .Name = "Idaho"})
states.Add(New State() With {.Abbreviation = "IL", .Name = "Illinois"})
states.Add(New State() With {.Abbreviation = "IN", .Name = "Indiana"})
states.Add(New State() With {.Abbreviation = "IA", .Name = "Iowa"})
states.Add(New State() With {.Abbreviation = "KS", .Name = "Kansas"})
states.Add(New State() With {.Abbreviation = "KY", .Name = "Kentucky"})
states.Add(New State() With {.Abbreviation = "LA", .Name = "Louisiana"})
states.Add(New State() With {.Abbreviation = "ME", .Name = "Maine"})
states.Add(New State() With {.Abbreviation = "MD", .Name = "Maryland"})
states.Add(New State() With {.Abbreviation = "MA", .Name = "Massachusetts"})
states.Add(New State() With {.Abbreviation = "MI", .Name = "Michigan"})
states.Add(New State() With {.Abbreviation = "MN", .Name = "Minnesota"})
states.Add(New State() With {.Abbreviation = "MS", .Name = "Mississippi"})
states.Add(New State() With {.Abbreviation = "MO", .Name = "Missouri"})
states.Add(New State() With {.Abbreviation = "MT", .Name = "Montana"})
states.Add(New State() With {.Abbreviation = "NE", .Name = "Nebraska"})
states.Add(New State() With {.Abbreviation = "NH", .Name = "New Hampshire"})
states.Add(New State() With {.Abbreviation = "NJ", .Name = "New Jersey"})
states.Add(New State() With {.Abbreviation = "NM", .Name = "New Mexico"})
states.Add(New State() With {.Abbreviation = "NY", .Name = "New York"})
states.Add(New State() With {.Abbreviation = "NC", .Name = "North Carolina"})
states.Add(New State() With {.Abbreviation = "NV", .Name = "Nevada"})
states.Add(New State() With {.Abbreviation = "ND", .Name = "North Dakota"})
states.Add(New State() With {.Abbreviation = "OH", .Name = "Ohio"})
states.Add(New State() With {.Abbreviation = "OK", .Name = "Oklahoma"})
states.Add(New State() With {.Abbreviation = "OR", .Name = "Oregon"})
states.Add(New State() With {.Abbreviation = "PA", .Name = "Pennsylvania"})
states.Add(New State() With {.Abbreviation = "RI", .Name = "Rhode Island"})
states.Add(New State() With {.Abbreviation = "SC", .Name = "South Carolina"})
states.Add(New State() With {.Abbreviation = "SD", .Name = "South Dakota"})
states.Add(New State() With {.Abbreviation = "TN", .Name = "Tennessee"})
states.Add(New State() With {.Abbreviation = "TX", .Name = "Texas"})
states.Add(New State() With {.Abbreviation = "UT", .Name = "Utah"})
states.Add(New State() With {.Abbreviation = "VT", .Name = "Vermont"})
states.Add(New State() With {.Abbreviation = "VA", .Name = "Virginia"})
states.Add(New State() With {.Abbreviation = "WA", .Name = "Washington"})
states.Add(New State() With {.Abbreviation = "WV", .Name = "West Virginia"})
states.Add(New State() With {.Abbreviation = "WI", .Name = "Wisconsin"})
states.Add(New State() With {.Abbreviation = "WY", .Name = "Wyoming"})
Return states.ToList()
End Function