/// ------------------------------------------------------------------------------------ private void SetupErrorDisplay(SearchQuery query) { _errorControl = new SearchQueryValidationErrorControl(query.Pattern, query.Errors, false) { Dock = DockStyle.Fill, }; Controls.Add(_errorControl); }
/// ------------------------------------------------------------------------------------ public void Initialize(string pattern, DataGridViewCell associatedCell) { Controls.Clear(); _associatedCell = associatedCell; var errors = associatedCell.Value as IEnumerable <SearchQueryValidationError>; var errorControl = new SearchQueryValidationErrorControl(pattern, errors.ToList(), true); errorControl.Dock = DockStyle.Fill; Height = errorControl.GetPreferredHeight(); Controls.Add(errorControl); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Refreshes the search results by performing the search again and rebuilding the /// grid contents. /// </summary> /// <param name="cieType"></param> /// ------------------------------------------------------------------------------------ public void RefreshResults(CIEOptions.CIEType cieType) { int savCurrRowIndex = 0; int savCurrColIndex = 0; int savFirstRowIndex = 0; SortOptions savSortOptions = null; CIEOptions savCIEOptions = null; if (_errorControl != null) { Controls.Remove(_errorControl); _errorControl.Dispose(); _errorControl = null; } if (_grid != null) { // Save the index of the row and column that's current, the // index of the first visible row, and the current sort options. savCurrRowIndex = (_grid.CurrentRow != null ? _grid.CurrentRow.Index : 0); savCurrColIndex = (_grid.CurrentCell != null ? _grid.CurrentCell.ColumnIndex : 0); savFirstRowIndex = _grid.FirstDisplayedScrollingRowIndex; savSortOptions = _grid.SortOptions; savCIEOptions = _grid.CIEOptions; if (savCIEOptions != null) { savCIEOptions.CieType = cieType; } } App.InitializeProgressBar(App.kstidQuerySearchingMsg); var resultCache = App.Search(_query); if (resultCache != null) { resultCache.SearchQuery = _query; Initialize(resultCache); } // Restore the current row to what it was before // rebuilding. Then make sure the row is visible. if (_grid != null) { _grid.PostDataSourceModifiedRestore(savCurrRowIndex, savCurrColIndex, savFirstRowIndex, savSortOptions, savCIEOptions); } App.UninitializeProgressBar(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// For some reason, this is safer to do in a Disposed delegate than in an override /// of the Dispose method. Putting this in an override of Dispose sometimes throws /// a "Parameter is not valid" exception. /// </summary> /// ------------------------------------------------------------------------------------ void SearchResultView_Disposed(object sender, EventArgs e) { Disposed -= SearchResultView_Disposed; if (_grid != null) { _grid.Dispose(); _grid = null; } if (_errorControl != null) { _errorControl.Dispose(); _errorControl = null; } }