Answer the question
In order to leave comments, you need to log in
How to implement column sorting in C# datagridview by clicking on the header?
Hello. A problem has arisen. It is necessary that by clicking on the column heading, the list items in the datagrid are sorted by this column. They are presented as a List. How can I do that?
Answer the question
In order to leave comments, you need to log in
bool x;
private void button1_Click(object sender, EventArgs e)
{
// сортировка поочерёдно в обе стороны по первому столбцу
dataGridView1.Sort(dataGridView1.Columns[0], x ? ListSortDirection.Ascending : ListSortDirection.Descending);
x = !x;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question