Converting country names into thier own ThreeLetterISORegionName with RegionInfo (c# 2013 Winforms)

243 Views Asked by At

I’ve already written every country’s name in a ComboBox but now i want to get each country’s ThreeLetterISORegionName when i click the country’s name in the ComboBox and display it in a label, is that possible? Thanks

1

There are 1 best solutions below

3
On BEST ANSWER

In your ComboBox's SelectedIndexChanged event, you could declare a new RegionInfo from the selected country, determine its ThreeLetterISORegionName, and set the label to it, like so:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
        RegionInfo ri = new RegionInfo(comboBox1.Items[comboBox1.SelectedIndex].ToString());
        Label1.Text = ri.ThreeLetterISORegionName;
    }