Creating a new method from a code fragment in an existing method.
We're going to create a new method from the datagridview binding and sorting snippet and name it SortGrid(). The resulting code is below.
private void SortGrid()
{
this.dataGridView1.DataSource = this.messageBS;
this.dataGridView1.Sort(this.dataGridView1.Columns[2], ListSortDirection.Descending);
}