Home Bind list from class to combobox
Reply: 0

Bind list from class to combobox

user1283
1#
user1283 Published in May 20, 2018, 9:59 am

I'm currently writing a pretty small program in C# and have this list that I want to bind to a combobox. Now, I've put that list in a class, and want to bind that list to a combobox. The code below shows how far I've come so far:

Form

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();
        Locaties locaties = new Locaties();
        List<string> listofLocaties = locaties.retrieveLocations();

        cboxLocToevoegen.DataSource = ???;
        cboxLocOverzicht.DataSource = ???;

    }
}

Class

class Locaties
{
    public List<string> retrieveLocations()
    {
        List<string> LocatieList = new List<string>();
        LocatieList.Add("Koelkast");
        LocatieList.Add("Keukenlade");
        LocatieList.Add("Voorraadruimte");
        LocatieList.Add("Overige");

        return LocatieList;
    }
}

Now, I'm gonna be honest with you: my knowledge and experience with classes and methods is not perfect. That's why the solution might probably be simpler than I think. Please don't judge me on that, I'm still learning!

Anyway, I hope anyone can help me out with this!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313857 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO