Esempio n. 1
0
        /// <summary>
        /// Enable a Filter and Sort on a DataGridViewColumn
        /// </summary>
        /// <param name="column"></param>
        public void EnableFilterAndSort(DataGridViewColumn column)
        {
            if (Columns.Contains(column))
            {
                ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
                if (cell != null)
                {
                    if (!cell.FilterAndSortEnabled && (cell.FilterString.Length > 0 || cell.SortString.Length > 0))
                    {
                        CleanFilter(true);
                    }

                    cell.FilterAndSortEnabled = true;
                    _filteredColumns.Remove(column.Name);

                    SetFilterDateAndTimeEnabled(column, cell.IsFilterDateAndTimeEnabled);
                    SetSortEnabled(column, cell.IsSortEnabled);
                    SetFilterEnabled(column, cell.IsFilterEnabled);
                }
                else
                {
                    column.SortMode     = DataGridViewColumnSortMode.Programmatic;
                    cell                = new ColumnHeaderCell(column.HeaderCell, true);
                    cell.SortChanged   += new ColumnHeaderCellEventHandler(Cell_SortChanged);
                    cell.FilterChanged += new ColumnHeaderCellEventHandler(Cell_FilterChanged);
                    cell.FilterPopup   += new ColumnHeaderCellEventHandler(Cell_FilterPopup);
                    column.MinimumWidth = cell.MinimumSize.Width;
                    if (ColumnHeadersHeight < cell.MinimumSize.Height)
                    {
                        ColumnHeadersHeight = cell.MinimumSize.Height;
                    }
                    column.HeaderCell = cell;
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Build the complete Sort string
        /// </summary>
        /// <returns></returns>
        private string BuildSortString()
        {
            StringBuilder sb   = new StringBuilder("");
            string        appx = "";

            foreach (string sortOrder in _sortOrderList)
            {
                DataGridViewColumn column = Columns[sortOrder];

                if (column != null)
                {
                    ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
                    if (cell != null)
                    {
                        if (cell.FilterAndSortEnabled && cell.ActiveSortType != MenuStrip.SortType.None)
                        {
                            sb.AppendFormat(appx + cell.SortString, column.DataPropertyName);
                            appx = ", ";
                        }
                    }
                }
            }

            return(sb.ToString());
        }
Esempio n. 3
0
 /// <summary>
 /// Set the text filter search nodes behaviour
 /// </summary>
 public void SetTextFilterRemoveNodesOnSearch(DataGridViewColumn column, bool enabled)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             cell.DoesTextFilterRemoveNodesOnSearch = enabled;
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Enable or disable Text filter on checklist remove node mode for a DataGridViewColumn
 /// </summary>
 /// <param name="column"></param>
 /// <param name="enabled"></param>
 public void SetChecklistTextFilterRemoveNodesOnSearchMode(DataGridViewColumn column, bool enabled)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             cell.SetChecklistTextFilterRemoveNodesOnSearchMode(enabled);
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Enable or disable Filter capabilities for a DataGridViewColumn
 /// </summary>
 /// <param name="column"></param>
 /// <param name="enabled"></param>
 public void SetFilterEnabled(DataGridViewColumn column, bool enabled)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             cell.SetFilterEnabled(enabled);
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Sort ASC
 /// </summary>
 public void SortDESC(DataGridViewColumn column)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             cell.SortDESC();
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Enable a Filter custom on a DataGridViewColumn
 /// </summary>
 /// <param name="column"></param>
 public void EnableFilterCustom(DataGridViewColumn column)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             cell.SetFilterCustomEnabled(true);
         }
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Disable a Filter checklist on a DataGridViewColumn
 /// </summary>
 /// <param name="column"></param>
 public void DisableFilterChecklist(DataGridViewColumn column)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             cell.SetFilterChecklistEnabled(false);
         }
     }
 }
Esempio n. 9
0
        /// <summary>
        /// Get the text filter search nodes behaviour
        /// </summary>
        public Nullable <bool> GetTextFilterRemoveNodesOnSearch(DataGridViewColumn column)
        {
            Nullable <bool> ret = null;

            if (Columns.Contains(column))
            {
                ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
                if (cell != null)
                {
                    ret = cell.DoesTextFilterRemoveNodesOnSearch;
                }
            }
            return(ret);
        }
Esempio n. 10
0
        /// <summary>
        /// Overridden OnColumnRemoved event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnColumnRemoved(DataGridViewColumnEventArgs e)
        {
            _filteredColumns.Remove(e.Column.Name);
            _filterOrderList.Remove(e.Column.Name);
            _sortOrderList.Remove(e.Column.Name);

            ColumnHeaderCell cell = e.Column.HeaderCell as ColumnHeaderCell;

            if (cell != null)
            {
                cell.SortChanged   -= Cell_SortChanged;
                cell.FilterChanged -= Cell_FilterChanged;
                cell.FilterPopup   -= Cell_FilterPopup;
            }
            base.OnColumnRemoved(e);
        }
Esempio n. 11
0
        /// <summary>
        /// Overriden  OnColumnAdded event
        /// </summary>
        /// <param name="e"></param>
        protected override void OnColumnAdded(DataGridViewColumnEventArgs e)
        {
            e.Column.SortMode = DataGridViewColumnSortMode.Programmatic;
            ColumnHeaderCell cell = new ColumnHeaderCell(e.Column.HeaderCell, FilterAndSortEnabled);

            cell.SortChanged     += new ColumnHeaderCellEventHandler(Cell_SortChanged);
            cell.FilterChanged   += new ColumnHeaderCellEventHandler(Cell_FilterChanged);
            cell.FilterPopup     += new ColumnHeaderCellEventHandler(Cell_FilterPopup);
            e.Column.MinimumWidth = cell.MinimumSize.Width;
            if (ColumnHeadersHeight < cell.MinimumSize.Height)
            {
                ColumnHeadersHeight = cell.MinimumSize.Height;
            }
            e.Column.HeaderCell = cell;

            base.OnColumnAdded(e);
        }
Esempio n. 12
0
 /// <summary>
 /// Disable a Filter and Sort on a DataGridViewColumn
 /// </summary>
 /// <param name="column"></param>
 public void DisableFilterAndSort(DataGridViewColumn column)
 {
     if (Columns.Contains(column))
     {
         ColumnHeaderCell cell = column.HeaderCell as ColumnHeaderCell;
         if (cell != null)
         {
             if (cell.FilterAndSortEnabled == true && (cell.SortString.Length > 0 || cell.FilterString.Length > 0))
             {
                 CleanFilter(true);
                 cell.FilterAndSortEnabled = false;
             }
             else
             {
                 cell.FilterAndSortEnabled = false;
             }
             _filterOrderList.Remove(column.Name);
             _sortOrderList.Remove(column.Name);
             _filteredColumns.Remove(column.Name);
         }
     }
 }
Esempio n. 13
0
        /// <summary>
        /// ColumnHeaderCell constructor
        /// </summary>
        /// <param name="oldCell"></param>
        /// <param name="filterEnabled"></param>
        public ColumnHeaderCell(DataGridViewColumnHeaderCell oldCell, bool filterEnabled)
            : base()
        {
            Tag              = oldCell.Tag;
            ErrorText        = oldCell.ErrorText;
            ToolTipText      = oldCell.ToolTipText;
            Value            = oldCell.Value;
            ValueType        = oldCell.ValueType;
            ContextMenuStrip = oldCell.ContextMenuStrip;
            Style            = oldCell.Style;
            _filterEnabled   = filterEnabled;

            ColumnHeaderCell oldCellt = oldCell as ColumnHeaderCell;

            if (oldCellt != null && oldCellt.MenuStrip != null)
            {
                MenuStrip                 = oldCellt.MenuStrip;
                _filterImage              = oldCellt._filterImage;
                _filterButtonPressed      = oldCellt._filterButtonPressed;
                _filterButtonOver         = oldCellt._filterButtonOver;
                _filterButtonOffsetBounds = oldCellt._filterButtonOffsetBounds;
                _filterButtonImageBounds  = oldCellt._filterButtonImageBounds;
                //MenuStrip.FilterChanged += new EventHandler(MenuStrip_FilterChanged);
                //MenuStrip.SortChanged += new EventHandler(MenuStrip_SortChanged);
            }
            else
            {
                MenuStrip = new MenuStrip(oldCell.OwningColumn.ValueType);
                ////MenuStrip.FilterChanged += new EventHandler(MenuStrip_FilterChanged);
                ////MenuStrip.SortChanged += new EventHandler(MenuStrip_SortChanged);
            }

            IsFilterDateAndTimeEnabled = FilterDateAndTimeDefaultEnabled;
            IsSortEnabled            = true;
            IsFilterEnabled          = true;
            IsFilterChecklistEnabled = true;
        }
Esempio n. 14
0
        /// <summary>
        /// Build the complete Filter string
        /// </summary>
        /// <returns></returns>
        private string BuildFilterString()
        {
            StringBuilder sb   = new StringBuilder("");
            string        appx = "";

            foreach (string filterOrder in _filterOrderList)
            {
                DataGridViewColumn Column = Columns[filterOrder];

                if (Column != null)
                {
                    ColumnHeaderCell cell = Column.HeaderCell as ColumnHeaderCell;
                    if (cell != null)
                    {
                        if (cell.FilterAndSortEnabled && cell.ActiveFilterType != MenuStrip.FilterType.None)
                        {
                            sb.AppendFormat(appx + "(" + cell.FilterString + ")", Column.DataPropertyName);
                            appx = " AND ";
                        }
                    }
                }
            }
            return(sb.ToString());
        }