PresFox
New member
- Joined
- Nov 2, 2021
- Messages
- 1
- Programming Experience
- Beginner
Hello,
I am reading a CSV file and putting the contents in a list, then trying to use that list as a DataSource for DataGridView:
However, I am getting the error that statusView is null. Any help would be appreciated.
I am reading a CSV file and putting the contents in a list, then trying to use that list as a DataSource for DataGridView:
C#:
public Form1()
{
List<string> cityList = File.ReadAllLines("cities.csv").ToList();
List<UrlList> toDoList = new List<UrlList>();
toDoList = File.ReadAllLines("todo.csv").Select(v => UrlList.FromCsv(v)).ToList();
var toDoListData = toDoList.Select(x => new {
Url = x.url,
City = x.city,
Done = x.done
}).ToList();
//UpdateList(toDoList);
statusView.DataSource = toDoListData;
InitializeComponent();
}
C#:
public class UrlList
{
public string url;
public string city;
public string done;
public static UrlList FromCsv(string csvline)
{
string[] values = csvline.Split(',');
UrlList urlList = new UrlList();
urlList.url = values[0];
urlList.city = values[1];
urlList.done = values[2];
return urlList;
}
}
However, I am getting the error that statusView is null. Any help would be appreciated.