Just getting back into the swing of things and trying not to develop from bad habits.
I have created a new project that currently reads in JSON via WebClient.DownloadString. The class identifies the items by name and this is stored in a List with this
I then make the DataSource connection.
Everything displays as expected.
Now I need to have the ability to Sort and Filter the datagrid.
I click on a column header which triggers the following:
The error that is returned says:
"DataGridView control must be bound to an IBindingList object to be sorted."
Where do I look for examples of doing this?
Is there a better way of achieving this without using a DataGridView?
Thank you,
I have created a new project that currently reads in JSON via WebClient.DownloadString. The class identifies the items by name and this is stored in a List with this
C#:
List<Member> members = JsonConvert.DesearlizeObject<List<Member>>(json);
C#:
dataGridView1.DataSource = members;
Now I need to have the ability to Sort and Filter the datagrid.
I click on a column header which triggers the following:
C#:
private void dataGridView1_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (dataGridView1.Columns[e.ColumnIndex].HeaderText == "State")
{
dataGridView1.Sort(dataGridView1.Columns["State"], ListSortDirection.Ascending);
}
}
"DataGridView control must be bound to an IBindingList object to be sorted."
Where do I look for examples of doing this?
Is there a better way of achieving this without using a DataGridView?
Thank you,
Last edited by a moderator: