I am trying to populate my checkedListBox with a txt file.
Here is my code:
public Form1()
{
StreamReader sr1 = new StreamReader(allatPath, Encoding.Default);
while(!sr1.EndOfStream)
{
allat = new Allat(sr1.ReadLine(), sr1.ReadLine(), Convert.ToInt32(sr1.ReadLine()), sr1.ReadLine());
allatok.Add(allat);
checkedListBox1.Items.Add(allat.Nev);
}
InitializeComponent();
}
I get the following error:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
checkedListBox1 was null.