I populate a ComboBox in C # from an instance of a class. How to get the selected item by receiving a link to the corresponding object? I have already used SelectedValue, SelectedItem, SelectedIndex, but they all return a string representation of my object.
thank
[EDIT]
Part of the code to show what I'm trying to do:
The filling part:
foreach (Business.IAuteur auteur in _livreManager.GetAuthors())
{
comboAuthor.Items.Add(auteur);
}
The receiving part is activated when the save button is pressed:
private void btnSave_Click(object sender, EventArgs e)
{
Business.IAuteur auteur = new Business.Auteur();
auteur = (Business.IAuteur)comboAuthor.SelectedValue;
toolStripStatusLabel1.Text = auteur.Nom;
}
Error message indicating here: toolStripStatusLabel1.Text = auteur.Nom;
The reference to the object is not set to the instance of the object.
source
share