BF2Statistics.AccountListForm.DataTable_ColumnHeaderMouseClick C# (CSharp) Method

DataTable_ColumnHeaderMouseClick() private method

Maunal Sorting of columns (Since Auto Sort sucks!)
private DataTable_ColumnHeaderMouseClick ( object sender, System.Windows.Forms.DataGridViewCellMouseEventArgs e ) : void
sender object
e System.Windows.Forms.DataGridViewCellMouseEventArgs
return void
        private void DataTable_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            DataGridViewColumn SelectedCol = DataTable.Columns[e.ColumnIndex];

            // Sort the same column again, reversing the SortOrder.
            if (SortedCol == SelectedCol)
            {
                SortDir = (SortDir == ListSortDirection.Ascending)
                    ? ListSortDirection.Descending
                    : ListSortDirection.Ascending;
            }
            else
            {
                // Sort a new column and remove the old SortGlyph.
                SortDir = ListSortDirection.Ascending;
                SortedCol.HeaderCell.SortGlyphDirection = SortOrder.None;
                SortedCol = SelectedCol;
            }

            // Set new Sort Glyph Direction
            SortedCol.HeaderCell.SortGlyphDirection = ((SortDir == ListSortDirection.Ascending)
                ? SortOrder.Ascending
                : SortOrder.Descending);

            // Build new List with database sort!
            BuildList();
        }