使用 RegionInfo 将国家/地区名称转换为自己的 ThreeLetterISORegionName(c# 2013 Winforms)

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

我已经在ComboBox中写了每个国家的名字,但现在我想在ComboBox中点击国家名称并显示在标签中时得到每个国家的ThreeLetterISORegionName,可以吗? 谢谢

在 ComboBox 的 SelectedIndexChanged 事件中,您可以从所选国家/地区声明一个新的 RegionInfo,确定其 ThreeLetterISORegionName,并为其设置标签,如下所示:

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