Enum on comboBox - Problem
Hi guys
I am working on a simple windows form application which has a simple class like this:
public class Movie
{
public enum Type
{
Comedy,
Action,
Horor,
Drama,
}
private string title;
private Type type;
public Movie(string title, Type type)
{
this.title = title;
this.type = type;
}
public Movie() { }
public string Title
{
get { return title; }
set { this.title = value; }
}
public Type MovieType
{
get { return type; }
set { this.type = value; }
}
public override string ToString()
{
return Title;
}
}
I also have a Form application
public partial class Form1 : Form
{
Movie film;
public Form1()
{
InitializeComponent();
}
private void btnAdd_Click(object sender, EventArgs e)
{
film.Title =txtInput.Text;
listMovie.Items.Add(film);
}
private void Form1_Load(object sender, EventArgs e)
{
{
comboBox1.Items.Add(film.MovieType.ToString());
}
}
}
which let the user to create a movie from by using txtInput and set the movie type by a combo box(enum)
Could you please how i can set the combobox to contains the values from my type enum?
as you can see I have :
comboBox1.Items.Add(film.MovieType.ToString());
but it just return just the first value(Comedy)!
Could you please let me know how i can fix this or let me know if there is any windows application examole or tutorial for enum?
Best regards