serching each cell and highlighting colour of cell

i have to searcheach cell and if condition matches i have to change colour of cell

2 Replies

DH dhana March 1, 2007 12:40 PM UTC


here is the code for searching the text in syncfusion grid

if(SearchText.Length > 0)

{

GridDataBoundGrid grid = this.dgCurrentTransaction;
grid.Focus();
dgCurrentTransaction.CurrentCell.MoveTo(this.dgCurrentTransaction.Model.Rows.HeaderCount,ItemNumber);
GridFindReplaceDialogSink fr = new GridFindReplaceDialogSink(grid);
GridCurrentCell cc = this.dgCurrentTransaction.CurrentCell;
GridRangeInfo frLocationInfo = GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex);
string str =(string)this.dgCurrentTransaction[cc.RowIndex, cc.ColIndex].Text;
if(SearchText!=frLocationInfo.ToString())
{
this.dgCurrentTransaction.Selections.Clear();
this.dgCurrentTransaction.BeginUpdate();
this.dgCurrentTransaction.Selections.Add(GridRangeInfo.Cells(this.dgCurrentTransaction.Model.Rows.HeaderCount ,ItemNumber,dgCurrentTransaction.Model.RowCount, dgCurrentTransaction.Model.ColCount));
GridFindReplaceEventArgs fre = new GridFindReplaceEventArgs(SearchText,"", GridFindTextOptions.SelectionOnly|GridFindTextOptions.MatchWholeCell, frLocationInfo);
fr.Find(fre);
if(fr.Find(fre) !=null)
{
grid.Selections.Clear();
this.dgCurrentTransaction.EndUpdate();
grid.Refresh();
}
else
{
grid.Selections.Clear();
this.dgCurrentTransaction.EndUpdate();
grid.Refresh();
string mstr;
mstr="Search text " + SearchText + " not found";
MessageBox.Show(mstr, "Search", MessageBoxButtons.OK ,MessageBoxIcon.Information);

}
}
else
{
MessageBox.Show("Record Not Found!!!!!!!");
}
}


AD Administrator Syncfusion Team March 1, 2007 06:46 PM UTC

Hi,

Here is a minimal sample that implements GridFindReplaceDialog for searching the cellvlues in a grid. It can be used without displaying the dialog. Please refer to the attached sample for more details.

GridControlFind.zip

Best Regards,
Haneef

Loader.
Up arrow icon