How to create a Winforms Combobox with Label and Value [C#]

    private void PopulateComboBox()
    {
        var dict = new Dictionary<int, string>();
        dict.Add(2324, "Toronto");
        dict.Add(64547, "Vancouver");
        dict.Add(42329, "Foobar");

        comboBox1.DataSource = new BindingSource(dict, null);
        comboBox1.DisplayMember = "Value";
        comboBox1.ValueMember = "Key";
    }

http://stackoverflow.com/a/2023457

Published by

sornram9254

Ayutthaya Technical College/Voc.Cert.🛠️ | KMUTNB/B.S.Tech.Ed.⚙️ | Information Security Engineer 👨🏻‍💻| Penetration Tester👨🏻‍💻 | COYG🔴 Milan🔴⚫️ | Taylor Swift👩‍🎤 | ติ่งซีรีส์ญี่ปุ่น 🇯🇵

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.