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!