SelecteIndexChanged
is called due to line:
annoAcquisti.SelectedIndex = 0;
and you are initializing _acquisti
after that. You can move the line before like:
public Form1()
{
InitializeComponent();
_acquisti = new Acquisti(); //move it here
WindowState = FormWindowState.Maximized;
for (int i = DateTime.Now.Year; i >= 2000; i--)
annoAcquisti.Items.Add(i);
annoAcquisti.SelectedIndex = 0;
}
Since the control moves to SelectedIndexChanged
event and at that point _acquisti
is still null, that is why you get the exception.