For some reason dataGridView isn't allowing me to sort it in any way when I'm using a list as a binding source. Any suggestions what to do to get alphabetical sorting working?
public partial class Form : Form
{
List<Person> people = new List<Person>();
string personsfile = "c:\\temp1\\people.json";
public Form()
{
InitializeComponent();
henkilot = DeserializeJSON();
if (people== null)
{
people= new List<Person>();
}
populateDataGrid();
}
public void SerializeJSON(List<Person> input)
{
string json = JsonConvert.SerializeObject(input);
//write string to file
System.IO.File.WriteAllText(personsfile, json);
}
public List<Person> DeserializeJSON()
{
if (File.Exists(personsfile))
{
using (StreamReader r = new StreamReader(personsfile))
{
string json = r.ReadToEnd();
return JsonConvert.DeserializeObject<List<Person>>(json);
}
}
else
return null;
}
public void populateDataGrid()
{
BindingSource source = new BindingSource();
source.DataSource = people;
dataGrid.DataSource = source;
}