void Edit(DBFilter filter) { ManageFiltersWindow filterWindow = new ManageFiltersWindow(filterList.Select(n => n.Name).ToList()); System.Windows.Forms.Integration.ElementHost.EnableModelessKeyboardInterop(filterWindow); filterWindow.CurrentTable = _parentDbController.CurrentTable; if (filterListView.SelectedItems.Count == 1) { filterWindow.Filter = filter; } filterWindow.ShowDialog(); if (filterWindow.DialogResult.Value) { DBFilter editedfilter = filterWindow.Filter; // Save the edited filter data. int index = filterList.IndexOf((DBFilter)filterListView.SelectedItem); filterList[index].Name = editedfilter.Name; filterList[index].ApplyToColumn = editedfilter.ApplyToColumn; filterList[index].FilterValue = editedfilter.FilterValue; filterList[index].MatchMode = editedfilter.MatchMode; if (editedfilter.IsActive) { _parentDbController.UpdateVisibleRows(); _parentDbController.dbDataGrid.Items.Refresh(); } SaveFilters(); } }
public static void DataGridRevertCellMenuItem(object sender, DBTableControl.DBEditorTableControl mainTable) { foreach (DataGridCellInfo cellinfo in mainTable.dbDataGrid.SelectedCells.Where(n => n.Item is DataRowView)) { // Ignore added or detached cells since they have no original values and will instead throw an error. if ((cellinfo.Item as DataRowView).Row.RowState == DataRowState.Detached || (cellinfo.Item as DataRowView).Row.RowState == DataRowState.Added) { continue; } int datarowindex = mainTable.CurrentTable.Rows.IndexOf((cellinfo.Item as DataRowView).Row); int datacolindex = mainTable.CurrentTable.Columns.IndexOf((string)cellinfo.Column.Header); // Make sure our visible rows are up to date and skip any currently filtered rows. if (mainTable._visibleRows.Count <= mainTable.CurrentTable.Rows.Count) { mainTable.UpdateVisibleRows(); } if (mainTable._visibleRows[datarowindex] == System.Windows.Visibility.Collapsed) { continue; } mainTable.CurrentTable.Rows[datarowindex][datacolindex] = mainTable.CurrentTable.Rows[datarowindex][datacolindex, DataRowVersion.Original]; } }
public static void ColumnMassEdit(object sender, DBTableControl.DBEditorTableControl mainTable) { DataGridColumn col = (((sender as MenuItem).Parent as ContextMenu).PlacementTarget as DataGridColumnHeader).Column; string colname = (string)col.Header; InputBox stringeditbox = new InputBox(); stringeditbox.Input = "{cell}"; stringeditbox.ShowDialog(); if (stringeditbox.DialogResult == System.Windows.Forms.DialogResult.OK) { int datacolindex = mainTable.CurrentTable.Columns.IndexOf(colname); for (int i = 0; i < mainTable.CurrentTable.Rows.Count; i++) { // Make sure our visible rows are up to date and skip any currently filtered rows. if (mainTable._visibleRows.Count <= mainTable.CurrentTable.Rows.Count) { mainTable.UpdateVisibleRows(); } if (mainTable._visibleRows[i] == System.Windows.Visibility.Collapsed) { continue; } mainTable.CurrentTable.Rows[i][datacolindex] = stringeditbox.Input.Replace("{cell}", mainTable.CurrentTable.Rows[i][datacolindex].ToString()); // Refresh the cell in the UI, using its visual coordinates. mainTable.RefreshCell(mainTable.dbDataGrid.Items.IndexOf(mainTable.CurrentTable.DefaultView[i]), mainTable.dbDataGrid.Columns.IndexOf(col)); } } }
public static void DataGridMassEditStringsMenuItem(object sender, DBTableControl.DBEditorTableControl mainTable) { InputBox stringeditbox = new InputBox(); stringeditbox.Input = "{cell}"; stringeditbox.ShowDialog(); if (stringeditbox.DialogResult == System.Windows.Forms.DialogResult.OK) { int datarowindex = -1; int datacolindex = -1; foreach (DataGridCellInfo cellinfo in mainTable.dbDataGrid.SelectedCells.Where(n => n.Item is DataRowView)) { datarowindex = mainTable.CurrentTable.Rows.IndexOf((cellinfo.Item as DataRowView).Row); datacolindex = mainTable.CurrentTable.Columns.IndexOf((string)cellinfo.Column.Header); // Make sure our visible rows are up to date and skip any currently filtered rows. if (mainTable._visibleRows.Count <= mainTable.CurrentTable.Rows.Count) { mainTable.UpdateVisibleRows(); } if (mainTable._visibleRows[datarowindex] == System.Windows.Visibility.Collapsed) { continue; } mainTable.CurrentTable.Rows[datarowindex][datacolindex] = stringeditbox.Input.Replace("{cell}", mainTable.CurrentTable.Rows[datarowindex][datacolindex].ToString()); // Refresh the cell in the UI, using its visual coordinates. mainTable.RefreshCell(mainTable.dbDataGrid.Items.IndexOf(cellinfo.Item), mainTable.dbDataGrid.Columns.IndexOf(cellinfo.Column)); } } }
public static void RowHeaderInsertManyRows(object sender, DBTableControl.DBEditorTableControl mainTable) { if (!mainTable.ReadOnly && sender is MenuItem) { // Request how many rows should be inserted from the user. InputBox insertrowsInputBox = new InputBox(); insertrowsInputBox.ShowDialog(); // Double check that whant triggered the event is what we expect. if (insertrowsInputBox.DialogResult == System.Windows.Forms.DialogResult.OK) { // Determine how many rows the user wants to add. int numrows = 0; try { numrows = int.Parse(insertrowsInputBox.Input); } catch (Exception ex) { if (ex is FormatException) { MessageBox.Show(String.Format("Input: {0}, is not a valid number of rows, please enter a whole number.", insertrowsInputBox.Input)); } else { #if DEBUG ErrorDialog.ShowDialog(ex); #endif } } for (int i = 0; i < numrows; i++) { DataRow newrow = mainTable.CurrentTable.NewRow(); if ((sender as MenuItem).DataContext is DataRowView) { mainTable.InsertRow(i); } else { try { // If the blank row is calling us, add to the end of the table. mainTable.InsertRow(); } catch (Exception ex) { #if DEBUG ErrorDialog.ShowDialog(ex); #endif } } } mainTable.UpdateVisibleRows(); mainTable.dbDataGrid.Items.Refresh(); } } }
private static bool PasteMatchesSelection(DBTableControl.DBEditorTableControl mainTable, string clipboardData) { // Build a blank clipboard copy from selected cells to compare to clipboardData string testSelection = ""; for (int i = 0; i < mainTable.CurrentTable.Rows.Count; i++) { // Additional error checking for the visibleRows internal list. if (i >= mainTable._visibleRows.Count) { mainTable.UpdateVisibleRows(); } // Ignore collapsed (filtered) rows when building our test string. if (mainTable._visibleRows[i] == System.Windows.Visibility.Collapsed) { continue; } bool writeEndofLine = false; int minColumnIndex = mainTable.dbDataGrid.SelectedCells.Min(n => n.Column.DisplayIndex); int maxColumnIndex = mainTable.dbDataGrid.SelectedCells.Max(n => n.Column.DisplayIndex); foreach (DataGridCellInfo cellinfo in mainTable.dbDataGrid.SelectedCells.Where(n => mainTable.CurrentTable.Rows.IndexOf((n.Item as DataRowView).Row) == i)) { for (int j = minColumnIndex; j < maxColumnIndex; j++) { testSelection += "\t"; } writeEndofLine = true; break; } if (writeEndofLine) { testSelection += "\r\n"; } } // If the number of lines don't match return false if (testSelection.Count(n => n == '\n') != clipboardData.Count(n => n == '\n')) { return(false); } // If the number of lines match, test each line for the same number of 'cells' foreach (string line in clipboardData.Split('\n')) { if (testSelection.Count(n => n == '\t') != clipboardData.Count(n => n == '\t')) { return(false); } } return(true); }
public static void DataGridApplyExpressionMenuItem(object sender, DBTableControl.DBEditorTableControl mainTable) { ApplyExpressionWindow getexpwindow = new ApplyExpressionWindow(); getexpwindow.ShowDialog(); if (getexpwindow.DialogResult != null && (bool)getexpwindow.DialogResult) { foreach (DataGridCellInfo cellinfo in mainTable.dbDataGrid.SelectedCells) { // Determine current cells indecies, row and column int columnindex = mainTable.CurrentTable.Columns.IndexOf((string)cellinfo.Column.Header); int rowindex = mainTable.CurrentTable.Rows.IndexOf((cellinfo.Item as DataRowView).Row); // Skip any filtered rows, or any rows with an error in the column we are computing. mainTable.UpdateVisibleRows(); if (mainTable._visibleRows[rowindex] == System.Windows.Visibility.Collapsed || mainTable._errorList.Count(n => n.RowIndex == rowindex && n.ColumnName.Equals((string)cellinfo.Column.Header)) > 0) { continue; } // Get the expression, replacing x for the current cell's value. string expression = getexpwindow.EnteredExpression.Replace("x", string.Format("{0}", mainTable.CurrentTable.Rows[rowindex][columnindex])); // Compute spits out the new value after the current value is applied to the expression given. object newvalue = mainTable.CurrentTable.Compute(expression, ""); // For integer based columns, do a round first if necessary. if (mainTable.EditedFile.CurrentType.Fields[columnindex].TypeCode == TypeCode.Int32 || mainTable.EditedFile.CurrentType.Fields[columnindex].TypeCode == TypeCode.Int16) { int newintvalue; if (!Int32.TryParse(newvalue.ToString(), out newintvalue)) { double tempvalue = Double.Parse(newvalue.ToString()); tempvalue = Math.Round(tempvalue, 0); newintvalue = (int)tempvalue; } newvalue = newintvalue; } mainTable.CurrentTable.Rows[rowindex][columnindex] = newvalue; // Refresh the cell in the UI, using its visual coordinates. mainTable.RefreshCell(mainTable.dbDataGrid.Items.IndexOf(cellinfo.Item), mainTable.dbDataGrid.Columns.IndexOf(cellinfo.Column)); } } }
public static void ColumnApplyExpression(object sender, DBTableControl.DBEditorTableControl mainTable) { DataGridColumn col = (((sender as MenuItem).Parent as ContextMenu).PlacementTarget as DataGridColumnHeader).Column; string colname = (string)col.Header; ApplyExpressionWindow getexpwindow = new ApplyExpressionWindow(); getexpwindow.ShowDialog(); if (getexpwindow.DialogResult != null && (bool)getexpwindow.DialogResult) { for (int i = 0; i < mainTable.CurrentTable.Rows.Count; i++) { // Skip any filtered rows, or any rows with an error in the column we are computing. mainTable.UpdateVisibleRows(); if (mainTable._visibleRows[i] == System.Windows.Visibility.Collapsed || mainTable._errorList.Count(n => n.RowIndex == i && n.ColumnName.Equals(colname)) > 0) { continue; } // Grab the given expression, modifying it for each cell. string expression = getexpwindow.EnteredExpression.Replace("x", string.Format("{0}", mainTable.CurrentTable.Rows[i][colname])); object newvalue = mainTable.CurrentTable.Compute(expression, ""); int colindex = mainTable.CurrentTable.Columns.IndexOf(colname); // For integer based columns, do a round first if necessary. if (mainTable.EditedFile.CurrentType.Fields[colindex].TypeCode == TypeCode.Int32 || mainTable.EditedFile.CurrentType.Fields[colindex].TypeCode == TypeCode.Int16) { int newintvalue; if (!Int32.TryParse(newvalue.ToString(), out newintvalue)) { double tempvalue = Double.Parse(newvalue.ToString()); tempvalue = Math.Round(tempvalue, 0); newintvalue = (int)tempvalue; } newvalue = newintvalue; } mainTable.CurrentTable.Rows[i][colname] = newvalue; } } mainTable.RefreshColumn(mainTable.dbDataGrid.Columns.IndexOf(col)); }
public static void OnExecutedPaste(DBTableControl.DBEditorTableControl mainTable) { string clipboarddata = GetClipboardText(); int rowindex; int datarowindex; int columnindex; int datacolumnindex; if (ClipboardIsEmpty()) { // Clipboard Empty } else if (ClipboardContainsSingleCell()) { // Single Cell Paste string pastevalue = clipboarddata.Trim(); foreach (DataGridCellInfo cellinfo in mainTable.dbDataGrid.SelectedCells) { // Get both visible and data row index rowindex = mainTable.dbDataGrid.Items.IndexOf(cellinfo.Item); datarowindex = mainTable.CurrentTable.Rows.IndexOf((cellinfo.Item as DataRowView).Row); // Additional error checking for the visibleRows internal list. if (datarowindex >= mainTable._visibleRows.Count) { mainTable.UpdateVisibleRows(); } // Selecting cells while the table is filtered will select collapsed rows, so skip them here. if (mainTable._visibleRows[datarowindex] == System.Windows.Visibility.Collapsed) { continue; } // Get both visible and data column index columnindex = mainTable.dbDataGrid.Columns.IndexOf(cellinfo.Column); datacolumnindex = mainTable.CurrentTable.Columns.IndexOf((string)cellinfo.Column.Header); mainTable.CurrentTable.Rows[datarowindex].BeginEdit(); if (!TryPasteValue(mainTable.CurrentTable, datarowindex, datacolumnindex, pastevalue)) { // Paste Error } mainTable.CurrentTable.Rows[datarowindex].EndEdit(); mainTable.RefreshCell(rowindex, columnindex); } } else if (!ClipboardContainsOnlyRows(mainTable)) { if (mainTable.dbDataGrid.SelectedItems.OfType <DataRowView>().Count() != mainTable.dbDataGrid.SelectedItems.Count) { // The blank row is selected, abort. MessageBox.Show("Only select the blank row when pasting rows.", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Warning); return; } // Use -1 values to indicate that nothing is selected, and to paste any full rows the // clipboard might contain as new rows. int basecolumnindex = -1; rowindex = -1; if (mainTable.dbDataGrid.SelectedCells.Count > 1) { // User has more than 1 cells selected, therefore the selection must match the clipboard data. if (!PasteMatchesSelection(mainTable, clipboarddata)) { // Warn user if (MessageBox.Show("Warning! Cell selection does not match copied data, attempt to paste anyway?", "Selection Error", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No) { return; } } // Set values to the first cell's coordinates // Get both visible and data row index rowindex = mainTable.dbDataGrid.Items.IndexOf(mainTable.dbDataGrid.SelectedCells[0].Item); basecolumnindex = mainTable.dbDataGrid.SelectedCells[0].Column.DisplayIndex; // Determine upper left corner of selection foreach (DataGridCellInfo cellinfo in mainTable.dbDataGrid.SelectedCells) { rowindex = Math.Min(rowindex, mainTable.dbDataGrid.Items.IndexOf(cellinfo.Item)); basecolumnindex = Math.Min(basecolumnindex, cellinfo.Column.DisplayIndex); } } else if (mainTable.dbDataGrid.SelectedCells.Count == 1) { // User has 1 cell selected, assume it is the top left corner and attempt to paste. rowindex = mainTable.dbDataGrid.Items.IndexOf(mainTable.dbDataGrid.SelectedCells[0].Item); basecolumnindex = mainTable.dbDataGrid.SelectedCells[0].Column.DisplayIndex; } List <string> pasteinstructions = new List <string>(); foreach (string line in clipboarddata.Split('\n')) { columnindex = basecolumnindex; if (rowindex > mainTable.CurrentTable.Rows.Count - 1 || columnindex == -1) { if (IsLineARow(mainTable, line)) { // We have a full row, but no where to paste it, so add it as a new row. DataRow newrow = mainTable.CurrentTable.NewRow(); if (mainTable.MoveAndFreezeKeys) { // Data is being displayed with keys moved, so assume the clipboard data matches the visual appearance and not // the order of the data source. object tempitem; List <object> itemarray = line.Split('\t').Take(mainTable.EditedFile.CurrentType.Fields.Count).ToList <object>(); for (int i = mainTable.CurrentTable.PrimaryKey.Count() - 1; i >= 0; i--) { tempitem = itemarray[i]; itemarray.RemoveAt(i); itemarray.Insert(mainTable.CurrentTable.Columns.IndexOf(mainTable.CurrentTable.PrimaryKey[i]), tempitem); } // Once we have reordered the clipboard data to match the data source, convert to an object[] newrow.ItemArray = itemarray.ToArray(); } else { // Data is displayed as it is stored, so assume the clipboard data is ordered the same way. newrow.ItemArray = line.Split('\t').Take(mainTable.EditedFile.CurrentType.Fields.Count).ToArray <object>(); } mainTable.CurrentTable.Rows.Add(newrow); } rowindex++; continue; } if (String.IsNullOrEmpty(line.Trim())) { rowindex++; continue; } // Convert visual row and column index to data row and column index. datarowindex = mainTable.CurrentTable.Rows.IndexOf((mainTable.dbDataGrid.Items[rowindex] as DataRowView).Row); // Additional error checking for the visibleRows internal list. if (datarowindex >= mainTable._visibleRows.Count) { mainTable.UpdateVisibleRows(); } // Skip past any collapsed (filtered) rows. while (mainTable._visibleRows[datarowindex] == System.Windows.Visibility.Collapsed) { rowindex++; datarowindex = mainTable.CurrentTable.Rows.IndexOf((mainTable.dbDataGrid.Items[rowindex] as DataRowView).Row); if (rowindex >= mainTable.CurrentTable.Rows.Count) { break; } } foreach (string cell in line.Replace("\r", "").Split('\t')) { if (columnindex > mainTable.CurrentTable.Columns.Count - 1) { break; } if (String.IsNullOrEmpty(cell.Trim())) { columnindex++; continue; } // Convert visual column index, the display index not its location in the datagrid's collection, to data column index. datacolumnindex = mainTable.CurrentTable.Columns.IndexOf((string)mainTable.dbDataGrid.Columns.Single(n => n.DisplayIndex == columnindex).Header); // Since refresh works on the visual tree, and the visual tree is not affected by DisplayIndex, find the columns location // in the datagrid's column collection to pass on. int refreshcolumnindex = mainTable.dbDataGrid.Columns.IndexOf(mainTable.dbDataGrid.Columns.Single(n => n.DisplayIndex == columnindex)); // Rather than attempting to modify cells as we go, we should modify them in batches // since any kind of sorting may interfere with paste order in real time. pasteinstructions.Add(String.Format("{0};{1};{2};{3};{4}", datarowindex, rowindex, datacolumnindex, refreshcolumnindex, cell)); columnindex++; } rowindex++; } // Now that we have a list of paste instructions, execute them simultaneously across the data source // to avoid interference from any visual resorting. // Instruction Format: Data Row index;Visual Row index;Data Column index;Visual Column index;value foreach (string instruction in pasteinstructions) { // Parse out the instructions. string[] parameters = instruction.Split(';'); datarowindex = int.Parse(parameters[0]); rowindex = int.Parse(parameters[1]); datacolumnindex = int.Parse(parameters[2]); columnindex = int.Parse(parameters[3]); // Edit currentTable mainTable.CurrentTable.Rows[datarowindex].BeginEdit(); mainTable.CurrentTable.Rows[datarowindex][datacolumnindex] = parameters[4]; mainTable.CurrentTable.Rows[datarowindex].EndEdit(); // Refresh the visual cell mainTable.RefreshCell(rowindex, columnindex); } } else { // Paste Rows, with no floater cells. if (mainTable.dbDataGrid.SelectedCells.Count == (mainTable.dbDataGrid.SelectedItems.Count * mainTable.EditedFile.CurrentType.Fields.Count)) { // Only rows are selected. // Since the SelectedItems list is in the order of selection and NOT in the order of appearance we need // to create a custom sorted list of indicies to paste to. List <int> indiciesToPaste = new List <int>(); List <int> dataindiciesToPaste = new List <int>(); int testindex; foreach (DataRowView rowview in mainTable.dbDataGrid.SelectedItems.OfType <DataRowView>()) { testindex = mainTable.CurrentTable.Rows.IndexOf(rowview.Row); // Additional error checking for the visibleRows internal list. if (testindex >= mainTable._visibleRows.Count) { mainTable.UpdateVisibleRows(); } // Skip any collapsed (filtered) rows. if (mainTable._visibleRows[testindex] == System.Windows.Visibility.Visible) { indiciesToPaste.Add(mainTable.dbDataGrid.Items.IndexOf(rowview)); } } indiciesToPaste.Sort(); // Now that we have the selected rows visual locations, we need to determine their locations in our data source. foreach (int i in indiciesToPaste) { dataindiciesToPaste.Add(mainTable.CurrentTable.Rows.IndexOf((mainTable.dbDataGrid.Items[i] as DataRowView).Row)); } // We now have a list of data indicies sorted in visual order. int currentindex = 0; foreach (string line in clipboarddata.Replace("\r", "").Split('\n')) { if (!IsLineARow(mainTable, line) || String.IsNullOrEmpty(line) || !IsRowValid(mainTable, line)) { currentindex++; continue; } if (currentindex >= dataindiciesToPaste.Count) { // Add new row DataRow newrow = mainTable.CurrentTable.NewRow(); if (mainTable.MoveAndFreezeKeys) { // Data is being displayed with keys moved, so assume the clipboard data matches the visual appearance and not // the order of the data source. object tempitem; List <object> itemarray = line.Split('\t').Take(mainTable.EditedFile.CurrentType.Fields.Count).ToList <object>(); for (int i = mainTable.CurrentTable.PrimaryKey.Count() - 1; i >= 0; i--) { tempitem = itemarray[i]; itemarray.RemoveAt(i); itemarray.Insert(mainTable.CurrentTable.Columns.IndexOf(mainTable.CurrentTable.PrimaryKey[i]), tempitem); } // Once we have reordered the clipboard data to match the data source, convert to an object[] newrow.ItemArray = itemarray.ToArray(); } else { // Data is displayed as it is stored, so assume the clipboard data is ordered the same way. newrow.ItemArray = line.Split('\t').Take(mainTable.EditedFile.CurrentType.Fields.Count).ToArray <object>(); } mainTable.CurrentTable.Rows.Add(newrow); currentindex++; continue; } mainTable.CurrentTable.Rows[dataindiciesToPaste[currentindex]].BeginEdit(); if (mainTable.MoveAndFreezeKeys) { // Data is being displayed with keys moved, so assume the clipboard data matches the visual appearance and not // the order of the data source. object tempitem; List <object> itemarray = line.Split('\t').Take(mainTable.EditedFile.CurrentType.Fields.Count).ToList <object>(); for (int i = mainTable.CurrentTable.PrimaryKey.Count() - 1; i >= 0; i--) { tempitem = itemarray[i]; itemarray.RemoveAt(i); itemarray.Insert(mainTable.CurrentTable.Columns.IndexOf(mainTable.CurrentTable.PrimaryKey[i]), tempitem); } // Once we have reordered the clipboard data to match the data source, convert to an object[] mainTable.CurrentTable.Rows[dataindiciesToPaste[currentindex]].ItemArray = itemarray.ToArray(); } else { // Data is displayed as it is stored, so assume the clipboard data is ordered the same way. mainTable.CurrentTable.Rows[dataindiciesToPaste[currentindex]].ItemArray = line.Split('\t').Take(mainTable.EditedFile.CurrentType.Fields.Count).ToArray <object>(); } mainTable.CurrentTable.Rows[dataindiciesToPaste[currentindex]].EndEdit(); currentindex++; } mainTable.Refresh(true); } else { // Please select rows. MessageBox.Show("When pasting rows, please use the row header button to select entire rows only.", "Selection Error", MessageBoxButton.OK, MessageBoxImage.Warning); } } }
private bool FindNext(string findthis) { if (String.IsNullOrEmpty(findthis)) { MessageBox.Show("Nothing entered in Find bar!"); return(false); } // Set starting point at table upper left. int rowstartindex = 0; int colstartindex = 0; // If the user has a single cell selected, assume this as starting point. if (_parentDbEdtiorTable.dbDataGrid.SelectedCells.Count == 1) { rowstartindex = _parentDbEdtiorTable.CurrentTable.Rows.IndexOf((_parentDbEdtiorTable.dbDataGrid.SelectedCells.First().Item as DataRowView).Row); colstartindex = _parentDbEdtiorTable.CurrentTable.Columns.IndexOf((string)_parentDbEdtiorTable.dbDataGrid.SelectedCells.First().Column.Header); } bool foundmatch = false; bool atstart = true; for (int i = rowstartindex; i < _parentDbEdtiorTable.dbDataGrid.Items.Count; i++) { // Additional error checking on the visibleRows internal list. if (i >= _parentDbEdtiorTable._visibleRows.Count) { _parentDbEdtiorTable.UpdateVisibleRows(); } // Ignore the blank row, and any collapsed (filtered) rows. if (!(_parentDbEdtiorTable.dbDataGrid.Items[i] is DataRowView) || _parentDbEdtiorTable._visibleRows[i] == System.Windows.Visibility.Collapsed) { continue; } for (int j = 0; j < _parentDbEdtiorTable.dbDataGrid.Columns.Count; j++) { if (atstart) { j = colstartindex; atstart = false; } // Skip current cell. if (i == rowstartindex && j == colstartindex) { continue; } foundmatch = DBUtil.isMatch(_parentDbEdtiorTable.CurrentTable.Rows[i][j].ToString(), findthis); if (foundmatch) { // Clears current selection for new selection. _parentDbEdtiorTable.dbDataGrid.SelectedCells.Clear(); _parentDbEdtiorTable.SelectCell(i, j, true); break; } } if (foundmatch) { break; } } if (!foundmatch) { MessageBox.Show("No More Matches Found."); } return(foundmatch); }