/// <summary> /// Displays the drop-down filter list. /// </summary> override public void ShowColumnFilter() { try { if (filterControlShowing) { HideFilterControl(); return; } // Cast the data source to a BindingSource. BindingSource data = this.DataGridView.DataSource as BindingSource; Debug.Assert((data != null && data.SupportsFiltering && OwningColumn != null) || (Retriever != null), "DataSource is not a BindingSource, or does not support filtering, or OwningColumn is null"); if (data != null) { throw new NotImplementedException(); } Debug.Assert(this.DataGridView != null, "DataGridView is null"); // Ensure that the current row is not the row for new records. // This prevents the new row from affecting the filter list and also // prevents the new row from being added when the filter changes. if (this.DataGridView.CurrentRow != null && this.DataGridView.CurrentRow.IsNewRow) { this.DataGridView.CurrentCell = null; } if (filterWindow != null) { this.DataGridView.Controls.Remove(filterWindow); filterWindow.Dispose(); } filterWindow = new DateTimeHeader(); // Add handlers to dropDownListBox.FilterListBox events. HandleDropDownListBoxEvents(); //textSelectBox.Visible = true; filterControlShowing = true; filterWindow.Show(this.DataGridView, m_dtpBefore, m_dtpAfter); // Set the size and location of dropDownListBox, then display it. SetDropDownListBoxBounds(); // Invalidate the cell so that the drop-down button will repaint // in the pressed state. this.DataGridView.InvalidateCell(this); } catch (Exception ex) { CErr.processError(ex, "Error while showing the column filter setting (" + this.OwningColumn.Name + ")"); } }
/// <summary> /// Hides the drop-down filter list. /// </summary> override protected void HideFilterControl() { if (filterControlShowing) { filterControlShowing = false; Debug.Assert(this.DataGridView != null, "DataGridView is null"); // Hide dropDownListBox.FilterListBox, remove handlers from its events, and remove // it from the DataGridView control. UnhandleDropDownListBoxEvents(); filterWindow.Visible = false; filterWindow.Dispose(); filterWindow = null; //this.DataGridView.Controls.Remove(multiSelectBox); // Invalidate the cell so that the drop-down button will repaint // in the unpressed state. this.DataGridView.InvalidateCell(this); this.DataGridView.Focus(); } }