예제 #1
0
        public void DisableFilter(DataGridViewColumn Column)
        {
            if (!this.Columns.Contains(Column))
            {
                return;
            }
            ADGVColumnHeaderCell headerCell = Column.HeaderCell as ADGVColumnHeaderCell;

            if (headerCell != null)
            {
                if (headerCell.FilterEnabled && (headerCell.SortString.Length > 0 || headerCell.FilterString.Length > 0))
                {
                    this.ClearFilter(true);
                    headerCell.FilterEnabled = false;
                }
                else
                {
                    headerCell.FilterEnabled = false;
                }
                this.filterOrder.Remove(Column.Name);
                this.sortOrder.Remove(Column.Name);
                this.readyToShowFilters.Remove(Column.Name);
            }
            Column.SortMode = DataGridViewColumnSortMode.Automatic;
        }
예제 #2
0
        private String CreateSortString()
        {
            StringBuilder sb = new StringBuilder("");

            foreach (string name in this.sortOrder)
            {
                DataGridViewColumn column = this.Columns[name];

                if (column != null)
                {
                    ADGVColumnHeaderCell cell = column.HeaderCell as ADGVColumnHeaderCell;
                    if (cell != null && cell.ActiveSortType != ADGVSortType.None)
                    {
                        sb.AppendFormat(cell.SortString + ", ", column.DataPropertyName);
                    }
                }
            }

            if (sb.Length > 2)
            {
                sb.Length -= 2;
            }

            return(sb.ToString());
        }
예제 #3
0
        public void ClearFilter(bool fireEvent = false, DataGridViewColumn column = null)
        {
            if (column == null)
            {
                foreach (ADGVColumnHeaderCell c in this.filterCells)
                {
                    c.ClearFilter();
                }

                this.filterOrder.Clear();
            }
            else if (this.Columns.Contains(column))
            {
                ADGVColumnHeaderCell cell = column.HeaderCell as ADGVColumnHeaderCell;

                if (cell != null)
                {
                    cell.ClearFilter();
                    this.filterOrder.Remove(column.Name);
                }
            }

            if (fireEvent)
            {
                this.FilterString = null;
            }
            else
            {
                this.filterString = null;
            }
        }
예제 #4
0
 public void Remove(ADGVColumnHeaderCell cell)
 {
     if (cell != null && cell.OwningColumn != null)
     {
         this.Remove(cell.OwningColumn.DataPropertyName);
     }
 }
예제 #5
0
        private String CreateSortString()
        {
            StringBuilder sb   = new StringBuilder("");
            String        appx = "";

            foreach (String name in this.sortOrder)
            {
                DataGridViewColumn Column = this.Columns[name];

                if (Column != null)
                {
                    ADGVColumnHeaderCell cell = Column.HeaderCell as ADGVColumnHeaderCell;
                    if (cell != null)
                    {
                        if (cell.FilterEnabled && cell.ActiveSortType != ADGVFilterMenuSortType.None)
                        {
                            sb.AppendFormat(appx + cell.SortString, Column.DataPropertyName);
                            appx = ", ";
                        }
                    }
                }
            }

            return(sb.ToString());
        }
예제 #6
0
        public ADGVColumnHeaderCell(DataGridViewColumnHeaderCell oldCell, Boolean FilterEnabled = false)
        {
            this.Tag              = oldCell.Tag;
            this.ErrorText        = oldCell.ErrorText;
            this.ToolTipText      = oldCell.ToolTipText;
            this.Value            = oldCell.Value;
            this.ValueType        = oldCell.ValueType;
            this.ContextMenuStrip = oldCell.ContextMenuStrip;
            this.Style            = oldCell.Style;
            this.filterEnabled    = FilterEnabled;

            ADGVColumnHeaderCell oldADGVCell = oldCell as ADGVColumnHeaderCell;

            if (oldADGVCell != null && oldADGVCell.FilterMenu != null)
            {
                this.FilterMenu               = oldADGVCell.FilterMenu;
                this.filterImage              = oldADGVCell.filterImage;
                this.filterButtonPressed      = oldADGVCell.filterButtonPressed;
                this.filterButtonOver         = oldADGVCell.filterButtonOver;
                this.filterButtonOffsetBounds = oldADGVCell.filterButtonOffsetBounds;
                this.filterButtonImageBounds  = oldADGVCell.filterButtonImageBounds;

                this.FilterMenu.FilterChanged += new EventHandler(FilterMenu_FilterChanged);
                this.FilterMenu.SortChanged   += new EventHandler(FilterMenu_SortChanged);
            }
            else
            {
                this.FilterMenu = new ADGVFilterMenu(oldCell.OwningColumn.ValueType);
                this.FilterMenu.FilterChanged += new EventHandler(FilterMenu_FilterChanged);
                this.FilterMenu.SortChanged   += new EventHandler(FilterMenu_SortChanged);
            }
        }
예제 #7
0
 public void Add(ADGVColumnHeaderCell cell)
 {
     if (cell != null && cell.OwningColumn != null)
     {
         this.RemoveAll(r => r.DataPropertyName == cell.OwningColumn.DataPropertyName);
         this.Add(new ADGVFilterRecord(cell.OwningColumn.DataPropertyName, cell.FilterString, cell.ActiveFilterType));
     }
 }
예제 #8
0
 public void EnableFilter(DataGridViewColumn Column)
 {
     if (this.Columns.Contains(Column))
     {
         ADGVColumnHeaderCell c = Column.HeaderCell as ADGVColumnHeaderCell;
         if (c != null)
         {
             this.EnableFilter(Column, c.DateWithTime, c.TimeFilter);
         }
         else
         {
             this.EnableFilter(Column, this.DateWithTime, this.TimeFilter);
         }
     }
 }
예제 #9
0
        protected override void OnColumnRemoved(DataGridViewColumnEventArgs e)
        {
            this.readyToShowFilters.Remove(e.Column.Name);
            this.filterOrder.Remove(e.Column.Name);
            this.sortOrder.Remove(e.Column.Name);
            ADGVColumnHeaderCell headerCell = e.Column.HeaderCell as ADGVColumnHeaderCell;

            if (headerCell != null)
            {
                headerCell.SortChanged   -= new ADGVFilterEventHandler(this.eSortChanged);
                headerCell.FilterChanged -= new ADGVFilterEventHandler(this.eFilterChanged);
                headerCell.FilterPopup   -= new ADGVFilterEventHandler(this.eFilterPopup);
            }
            base.OnColumnRemoved(e);
        }
예제 #10
0
        protected override void OnColumnRemoved(DataGridViewColumnEventArgs e)
        {
            this.readyToShowFilters.Remove(e.Column.Name);
            this.filterOrder.Remove(e.Column.Name);
            this.sortOrder.Remove(e.Column.Name);

            ADGVColumnHeaderCell cell = e.Column.HeaderCell as ADGVColumnHeaderCell;

            if (cell != null)
            {
                cell.SortChanged   -= eSortChanged;
                cell.FilterChanged -= eFilterChanged;
                cell.FilterPopup   -= eFilterPopup;
            }
            base.OnColumnRemoved(e);
        }
예제 #11
0
        public void EnableFilter(DataGridViewColumn Column)
        {
            if (!this.Columns.Contains(Column))
            {
                return;
            }
            ADGVColumnHeaderCell headerCell = Column.HeaderCell as ADGVColumnHeaderCell;

            if (headerCell != null)
            {
                this.EnableFilter(Column, headerCell.DateWithTime, headerCell.TimeFilter);
            }
            else
            {
                this.EnableFilter(Column, this.DateWithTime, this.TimeFilter);
            }
        }
예제 #12
0
        protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
        {
            e.Column.SortMode = DataGridViewColumnSortMode.Programmatic;
            ADGVColumnHeaderCell cell = new ADGVColumnHeaderCell(e.Column.HeaderCell, this.DefaultCellBehavior);

            cell.SortChanged     += new ADGVFilterEventHandler(eSortChanged);
            cell.FilterChanged   += new ADGVFilterEventHandler(eFilterChanged);
            cell.FilterPopup     += new ADGVFilterEventHandler(eFilterPopup);
            cell.DateTimeGrouping = this.DefaultDateTimeGrouping;
            e.Column.MinimumWidth = cell.MinimumSize.Width;
            if (this.ColumnHeadersHeight < cell.MinimumSize.Height)
            {
                this.ColumnHeadersHeight = cell.MinimumSize.Height;
            }
            e.Column.HeaderCell = cell;

            base.OnColumnAdded(e);
        }
예제 #13
0
        protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
        {
            e.Column.SortMode = DataGridViewColumnSortMode.Programmatic;
            ADGVColumnHeaderCell columnHeaderCell = new ADGVColumnHeaderCell(e.Column.HeaderCell, this.AutoGenerateContextFilters);

            columnHeaderCell.DateWithTime   = this.DateWithTime;
            columnHeaderCell.TimeFilter     = this.TimeFilter;
            columnHeaderCell.SortChanged   += new ADGVFilterEventHandler(this.eSortChanged);
            columnHeaderCell.FilterChanged += new ADGVFilterEventHandler(this.eFilterChanged);
            columnHeaderCell.FilterPopup   += new ADGVFilterEventHandler(this.eFilterPopup);
            e.Column.MinimumWidth           = columnHeaderCell.MinimumSize.Width;
            if (this.ColumnHeadersHeight < columnHeaderCell.MinimumSize.Height)
            {
                this.ColumnHeadersHeight = columnHeaderCell.MinimumSize.Height;
            }
            e.Column.HeaderCell = (DataGridViewColumnHeaderCell)columnHeaderCell;
            base.OnColumnAdded(e);
        }
예제 #14
0
        private string CreateSortString()
        {
            StringBuilder stringBuilder = new StringBuilder("");
            string        str           = "";

            foreach (string index in this.sortOrder)
            {
                DataGridViewColumn column = this.Columns[index];
                if (column != null)
                {
                    ADGVColumnHeaderCell headerCell = column.HeaderCell as ADGVColumnHeaderCell;
                    if (headerCell != null && headerCell.FilterEnabled && headerCell.ActiveSortType != ADGVFilterMenuSortType.None)
                    {
                        stringBuilder.AppendFormat(str + headerCell.SortString, (object)column.DataPropertyName);
                        str = ", ";
                    }
                }
            }
            return(stringBuilder.ToString());
        }
예제 #15
0
 public void SetFilterBehavior(ADGVColumnHeaderCellBehavior behavior, DataGridViewColumn column = null)
 {
     if (column == null)
     {
         foreach (DataGridViewColumn c in this.Columns)
         {
             ADGVColumnHeaderCell cell = c.HeaderCell as ADGVColumnHeaderCell;
             if (cell != null)
             {
                 cell.CellBehavior = behavior;
             }
         }
     }
     else if (this.Columns.Contains(column))
     {
         ADGVColumnHeaderCell cell = column.HeaderCell as ADGVColumnHeaderCell;
         if (cell != null)
         {
             cell.CellBehavior = behavior;
         }
     }
 }
예제 #16
0
 public void SetFilterDateTimeGrouping(ADGVFilterMenuDateTimeGrouping grouping, DataGridViewColumn column = null)
 {
     if (column == null)
     {
         foreach (DataGridViewColumn c in this.Columns)
         {
             ADGVColumnHeaderCell cell = c.HeaderCell as ADGVColumnHeaderCell;
             if (cell != null)
             {
                 cell.DateTimeGrouping = grouping;
             }
         }
     }
     else if (this.Columns.Contains(column))
     {
         ADGVColumnHeaderCell cell = column.HeaderCell as ADGVColumnHeaderCell;
         if (cell != null)
         {
             cell.DateTimeGrouping = grouping;
         }
     }
 }
예제 #17
0
        public ADGVColumnHeaderCell(DataGridViewColumnHeaderCell oldCell, ADGVColumnHeaderCellBehavior cellBehavior)
        {
            this.Tag              = oldCell.Tag;
            this.ErrorText        = oldCell.ErrorText;
            this.ToolTipText      = oldCell.ToolTipText;
            this.Value            = oldCell.Value;
            this.ValueType        = oldCell.ValueType;
            this.ContextMenuStrip = oldCell.ContextMenuStrip;
            this.Style            = oldCell.Style;
            this.cellBehavior     = cellBehavior;

            ADGVColumnHeaderCell oldADGVCell = oldCell as ADGVColumnHeaderCell;

            if (oldADGVCell != null)
            {
                if (oldADGVCell.FilterMenu != null)
                {
                    this.FilterMenu = oldADGVCell.FilterMenu.Clone() as ADGVFilterMenu;
                }
                else
                {
                    this.FilterMenu = new ADGVFilterMenu(oldCell.OwningColumn.ValueType);
                }

                this.filterButtonPressed      = oldADGVCell.filterButtonPressed;
                this.filterButtonOver         = oldADGVCell.filterButtonOver;
                this.filterButtonOffsetBounds = oldADGVCell.filterButtonOffsetBounds;
                this.filterButtonImageBounds  = oldADGVCell.filterButtonImageBounds;
            }
            else
            {
                this.FilterMenu = new ADGVFilterMenu(oldCell.OwningColumn.ValueType);
            }

            this.FilterMenu.FilterChanged           += FilterMenu_FilterChanged;
            this.FilterMenu.SortChanged             += FilterMenu_SortChanged;
            this.FilterMenu.DateTimeGroupingChanged += FilterMenu_DateTimeGroupingChanged;
        }
예제 #18
0
        public void EnableFilter(DataGridViewColumn Column, bool DateWithTime, bool TimeFilter)
        {
            if (!this.Columns.Contains(Column))
            {
                return;
            }
            ADGVColumnHeaderCell headerCell = Column.HeaderCell as ADGVColumnHeaderCell;

            if (headerCell != null)
            {
                if (headerCell.DateWithTime != DateWithTime || headerCell.TimeFilter != TimeFilter || !headerCell.FilterEnabled && (headerCell.FilterString.Length > 0 || headerCell.SortString.Length > 0))
                {
                    this.ClearFilter(true);
                }
                headerCell.DateWithTime  = DateWithTime;
                headerCell.TimeFilter    = TimeFilter;
                headerCell.FilterEnabled = true;
                this.readyToShowFilters.Remove(Column.Name);
            }
            else
            {
                Column.SortMode = DataGridViewColumnSortMode.Programmatic;
                ADGVColumnHeaderCell columnHeaderCell = new ADGVColumnHeaderCell(Column.HeaderCell, true);
                columnHeaderCell.DateWithTime   = this.DateWithTime;
                columnHeaderCell.TimeFilter     = this.TimeFilter;
                columnHeaderCell.SortChanged   += new ADGVFilterEventHandler(this.eSortChanged);
                columnHeaderCell.FilterChanged += new ADGVFilterEventHandler(this.eFilterChanged);
                columnHeaderCell.FilterPopup   += new ADGVFilterEventHandler(this.eFilterPopup);
                Column.MinimumWidth             = columnHeaderCell.MinimumSize.Width;
                if (this.ColumnHeadersHeight < columnHeaderCell.MinimumSize.Height)
                {
                    this.ColumnHeadersHeight = columnHeaderCell.MinimumSize.Height;
                }
                Column.HeaderCell = (DataGridViewColumnHeaderCell)columnHeaderCell;
            }
            Column.SortMode = DataGridViewColumnSortMode.Programmatic;
        }
예제 #19
0
        private String CreateFilterString()
        {
            StringBuilder sb = new StringBuilder("");

            foreach (string name in this.filterOrder)
            {
                DataGridViewColumn column = this.Columns[name];

                if (column != null)
                {
                    ADGVColumnHeaderCell cell = column.HeaderCell as ADGVColumnHeaderCell;
                    if (cell != null && cell.ActiveFilterType != ADGVFilterType.None)
                    {
                        sb.AppendFormat("(" + cell.FilterString + ") AND ", column.DataPropertyName);
                    }
                }
            }
            if (sb.Length > 4)
            {
                sb.Length -= 4;
            }

            return(sb.ToString());
        }