Beispiel #1
0
        private void FirstPageSettings()
        {
            tbPage.Text = "1";
            PageNumber = 1;

            //Clear sort related settings.
            _hc = null;
            SortBy = string.Empty;

            SetPagerStatus(false, false, (TotalPages > 1), (TotalPages > 1));
        }
Beispiel #2
0
        private void SortAction(object sender, DataGridViewCellMouseEventArgs e, SortEventSequence eventSequence)
        {
            //Manual sort is made possible by changing sort mode of
            //each column. See BindDataGrid method to see this.
            DataGridView dg = sender as DataGridView;
            int colIndex = e.ColumnIndex;
            DataGridViewColumnHeaderCell hc = dg.Columns[colIndex].HeaderCell;
            DataGridViewColumn col = dg.Columns[colIndex];

            if (hc.SortGlyphDirection == SortOrder.None
                || (col.Name != SortBy && !SortBy.Contains("DESC")))
            {
                if (eventSequence == SortEventSequence.Before) SortBy = col.Name;
                if (eventSequence == SortEventSequence.After) hc.SortGlyphDirection = SortOrder.Ascending;
            }
            else if (col.Name == SortBy)
            {
                if (eventSequence == SortEventSequence.Before) SortBy = string.Format("{0} DESC", col.Name);
                if (eventSequence == SortEventSequence.After) hc.SortGlyphDirection = SortOrder.Ascending;
            }
            else if (SortBy.Contains("DESC"))
            {
                if (eventSequence == SortEventSequence.Before) SortBy = col.Name;
                if (eventSequence == SortEventSequence.After) hc.SortGlyphDirection = SortOrder.Descending;
            }

            _hc = Clone(hc);
        }
Beispiel #3
0
 public static DataGridViewColumnHeaderCellCustom Clone(DataGridViewColumnHeaderCell hc)
 {
     //Had to build my own because DataGridViewColumnHeaderCellCustom's
     //clone didn't work.
     var toReturn = new DataGridViewColumnHeaderCellCustom();
     toReturn.ColumnIndex = hc.ColumnIndex;
     toReturn.SortGlyphDirection = hc.SortGlyphDirection;
     return toReturn;
 }