Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using ListPicker.Resources;


namespace ListPicker
{
    public partial class MainPage : PhoneApplicationPage
    {
        String[] Country = { "Viet Nam","Japan",
                              "China","USA",
                              "Poland","Brazil",
                              "Singapore","Philipin","Malaysia"};
        public MainPage()
        {
            InitializeComponent();
            this.lpkCountry.ItemsSource = Country;
        }

        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
           

            String _Content = String.Format("Country Code: {0} \nCountry: {1}",
                txtName.Text,  lpkCountry.SelectedItem);
            MessageBox.Show(_Content);
        }
    }
}


I want To Display Country Code in txtName.Text According to select country For that How Can i Write Code.Please Me Thanks in advance
Posted

Please check following link.
Hope so it'll resolve your issue.

ComboBox.SelectedIndexChanged Event
 
Share this answer
 
Change the type of your Country variable. String is only good to show that string. I'd use a custom class that wraps a CultureInfo[^]. This type provides country codes and your custom wrapper can make it appear like you need it:
C#
public class Country
{
    private System.Globalization.CultureInfo _innerCulture = null;

    public Country(string CountryCode)
    {
        _innerCulture = new CultureInfo(CountryCode);       // Add error handling
    }

    public override string ToString()
    {
        return(_innerCulture.EnglishName);
    }
}
I don't know what type lpkCountry is, but most controls simply show what ToString() returns. That way, the english names would appear in it (the list?).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900