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

  • J Medema

    J Medema

    11 EKİM 2006
  • Viktorija A.

    Viktorija A.

    28 Mart 2009
  • Vsauce

    Vsauce

    30 Temmuz 2007