public void AddFindResult(int rowIndex, int columnIndex)
        {
            if (HasFindResult(rowIndex, columnIndex))
            {
                return;
            }

            DataGridViewFindResultRow foundRow;

            var foundCell = new DataGridViewFindResultCell(rowIndex, columnIndex,
                                                           _findCellIndex);

            if (!_findResultRowsByIndex.TryGetValue(rowIndex, out foundRow))
            {
                AddCellToNewRow(foundCell, rowIndex);
            }
            else
            {
                foundRow.Add(foundCell);
            }

            FindResultCells.Add(foundCell);

            _findCellIndex++;
        }
        private void AddCellToNewRow([NotNull] DataGridViewFindResultCell foundCell,
                                     int rowIndex)
        {
            var newRow = new DataGridViewFindResultRow();

            newRow.Add(foundCell);

            FindResultRows.Add(newRow);

            _findResultRowsByIndex.Add(rowIndex, newRow);
        }
예제 #3
0
        private bool IsActiveCell(int rowIndex, int columnIndex)
        {
            if (_findResults == null ||
                CurrentFindResultIndex >= _findResults.FindResultCells.Count ||
                CurrentFindResultIndex < 0)
            {
                return(false);
            }

            DataGridViewFindResultCell currentFind =
                _findResults.FindResultCells[CurrentFindResultIndex];

            return(currentFind.RowIndex == rowIndex &&
                   currentFind.ColumnIndex == columnIndex);
        }
        public bool TryGetCell(int columnIndex, out DataGridViewFindResultCell foundCell)
        {
            foreach (DataGridViewFindResultCell findResultCell in _cells)
            {
                if (findResultCell.ColumnIndex != columnIndex)
                {
                    continue;
                }

                foundCell = findResultCell;
                return(true);
            }

            foundCell = null;
            return(false);
        }
예제 #5
0
        private void SetCurrentCell(bool restoreSelection)
        {
            DataGridViewSelectedRowCollection selectedRows = _dataGridView.SelectedRows;

            DataGridViewFindResultCell firstFindCell =
                Assert.NotNull(_findResults).FindResultCells[CurrentFindResultIndex];

            DataGridViewRow row = _dataGridView.Rows[firstFindCell.RowIndex];

            if (!row.Visible)
            {
                row.Visible = true;
            }

            _dataGridView.CurrentCell = row.Cells[firstFindCell.ColumnIndex];

            if (restoreSelection)
            {
                RestoreSelection(selectedRows);
            }
        }
 public void Add([NotNull] DataGridViewFindResultCell findCell)
 {
     _cells.Add(findCell);
 }