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

  • fouseyTUBE

    fouseyTUBE

    21 Mart 2011
  • khloe brooks

    khloe brooks

    25 Temmuz 2011
  • NikkoNantone

    NikkoNantone

    21 Kasım 2011