Example #1
0
        public void Filter(string searchString)
        {
            _filterSearchString = searchString;

            if (dataGridView.Rows.Count == 0)
            {
                return;
            }

            var searchResults = SearchEngineCommands.Search(searchString);
            var productIds    = searchResults.Docs.Select(d => d.ProductId).ToList();

            // https://stackoverflow.com/a/18942430
            var currencyManager = (CurrencyManager)BindingContext[dataGridView.DataSource];

            currencyManager.SuspendBinding();
            {
                for (var r = dataGridView.RowCount - 1; r >= 0; r--)
                {
                    dataGridView.Rows[r].Visible = productIds.Contains(getGridEntry(r).GetBook().AudibleProductId);
                }
            }
            currencyManager.ResumeBinding();
            VisibleCountChanged?.Invoke(this, dataGridView.AsEnumerable().Count(r => r.Visible));
        }
Example #2
0
        public void Filter(string searchString)
        {
            _filterSearchString = searchString;

            if (_dataGridView.Rows.Count == 0)
            {
                return;
            }

            var searchResults = SearchEngineCommands.Search(searchString);
            var productIds    = searchResults.Docs.Select(d => d.ProductId).ToList();

            // https://stackoverflow.com/a/18942430
            var bindingContext = BindingContext[_dataGridView.DataSource];

            bindingContext.SuspendBinding();
            {
                this.UIThreadSync(() =>
                {
                    for (var r = _dataGridView.RowCount - 1; r >= 0; r--)
                    {
                        _dataGridView.Rows[r].Visible = productIds.Contains(getGridEntry(r).AudibleProductId);
                    }
                });
            }

            //Causes repainting of the DataGridView
            bindingContext.ResumeBinding();
            VisibleCountChanged?.Invoke(this, _dataGridView.AsEnumerable().Count(r => r.Visible));
        }