SORU
17 HAZİRAN 2010, PERŞEMBE


ComboBox: bir Öğeyi (Bağlayıcı bir Kaynak)Metin ve katma Değer

C# Program ben ComboBox öğeleri için Metin ve Değer katabilir miyim? Bir arama ve genelde cevapları "kaynağına" ama benim durumumda bağlayıcı bir kaynak, programım hazır değilim.....Bağlama kullanarak yaptım Nasıl böyle bir şey yapabilirim:

combo1.Item[1] = "DisplayText";
combo1.Item[1].Value = "useful Value"

CEVAP
31 Temmuz 2012, Salı


// Bind combobox to dictionary
Dictionary<string, string>test = new Dictionary<string, string>();
        test.Add("1", "dfdfdf");
        test.Add("2", "dfdfdf");
        test.Add("3", "dfdfdf");
        comboBox1.DataSource = new BindingSource(test, null);
        comboBox1.DisplayMember = "Value";
        comboBox1.ValueMember = "Key";

// Get combobox selection (in handler)
string value = ((KeyValuePair<string, string>)comboBox1.SelectedItem).Value;

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Canal de arkyoru

    Canal de ark

    18 Ocak 2007
  • buttheadgsxr1000

    buttheadgsxr

    24 Ocak 2008
  • RayperEnglishKnight

    RayperEnglis

    24 Kasım 2008