This sample features support for performing search-and-replace operations with the Grid Grouping Control.
Find and Replace
Features
It allows you to do the following actions with data records in the grouping grid:
It also explores various search options such as whether to ignore case or perform search only in a current column or whole table. The GridFindTextOptions defines the possible search options for grid data.
The available search options are listed and explained below.
Implementation
Below are sample code snippets that implement these operations. The QueryCellStyleInfo event is handled to implement the FindAll operation; it highlights all the data records containing the search string.
Find
GridFindReplaceEventArgs frEvents = new GridFindReplaceEventArgs(txtSearch.Text, "", searchOptions, locInfo);
GridFindReplaceDialogSink frDialog = new GridFindReplaceDialogSink(gridGroupingControl1.TableControl);
frDialog.Find(frEvents);
Replace
GridFindReplaceEventArgs frEvents = new GridFindReplaceEventArgs(txtSearch.Text, txtReplace.Text, searchOptions, locInfo);
GridFindReplaceDialogSink frDialog = new GridFindReplaceDialogSink(gridGroupingControl1.TableControl);
frDialog.Replace(frEvents);
Replace All
GridFindReplaceEventArgs frEvents = new GridFindReplaceEventArgs(txtSearch.Text, txtReplace.Text, searchOptions, locInfo);
GridFindReplaceDialogSink frDialog = new GridFindReplaceDialogSink(gridGroupingControl1.TableControl);
frDialog.ReplaceAll(frEvents);
Find All by Query Cell Style Info
void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
DataRowView dr = e.TableCellIdentity.DisplayElement.GetData() as DataRowView;
GridRangeInfo range = gridGroupingControl1.TableControl.Selections.Ranges.ActiveRange;
if (cmbOptions.Text.Equals("WholeTable") && dr != null)
{
for (int i = 0; i < gridGroupingControl1.TableModel.ColCount-2; i++)
if (dr[i].Equals(txtSearch.Text))
{
e.Style.BackColor = Color.Orange;
break;
}
}
}