Link to home
Start Free TrialLog in
Avatar of dotnetpro
dotnetpro

asked on

Hightlighting searched text

Experts,

I am using a sample third party grid from SyncFusion(they wont support unless i am ready to buy) and I am using one of their Grid control to impplment search functionality.
Following code gives me tells me whether the cell contains the searched value:
gridControl.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].Text.Contains(SearchValue)
All i am trying to do is that instead of highlighting the whole cell using the code :
gridControl.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].Background = Brushes.Yellow;
I  want to only highlight the matching text. Can you please help me with this urgent issue ?
Avatar of grishav
grishav

Hi,
I don't think that you have obvious way to do this - no matter which grid you use.
You probably need to make a DataTemplate for you cell content and specify that it consists
from 3 text blocks - one for the substring of the text before selection, one for selected text, and one for the rest of string.
You should get rid of margins&padding to get the smooth picture of the whole text.
And you still must maintain string property for the whole text in your data class.

In "normal" cell you can just set the text in the first block to be the whole string and make the rest an empty string.
While searching, when you see that the cell text matches the pattern,
you need to split the string into 3 parts, assign values to the properties which are bound to the content of 3 text blocks and change background only for the second one.
Avatar of dotnetpro

ASKER

Can you please give me a quick example as well ?
ASKER CERTIFIED SOLUTION
Avatar of grishav
grishav

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial