C1FlexGrid.ApplySearch highlights only first match per cell

Posted by: wknauf on 26 October 2020, 3:49 am EST

  • Posted 26 October 2020, 3:49 am EST

    Hi C1,

    it seems that "C1FlexGrid.ApplySearch (myString, true, false)" just highlights the first match per call.

    I use it for a code search and replace preview form, see attached screenshot. As the search string might occur multiple times per row, I would like to see a highlight for each match.

    Bonus question: my use case is a bit special: when I find a string in a code line, I also render the lines before and after in the grid. And here I would like not to show the search match highlight - just in the "middle line". But this is probably impossible to achieve?

  • Replied 27 October 2020, 5:49 pm EST

    Hi Wolfgang,

    You will have to manually highlight the search results if you want to highlight all occurrences, you can use the OwnerDrawCell event and then manually draw the text. I have used the MeasureCharacterRanges method to get the bounds of the match and then redraw the text after drawing the filled highlight rectangle for it. Please refer to the sample attached.

    Bonus question:

    Since we have to manually draw the matches and add character ranges to get the bounds of matches, you can add character ranges of only the line in which you want to show the matches, but for that, you will require some kind of identifier which in your case is Line no.

    If you meant something else then please let us know in brief.

    Prabhat Sharma.
  • Replied 27 October 2020, 11:02 pm EST

    Hi Prabhat,

    many, many thanks for the sample! I was afraid of using the OwnerDrawCell event, but your sample and especially the text parsing/splitting helped a lot!
    I would offer a beer, but we will never meet for sure ;-)

    One might consider it a bug the C1FlexGrid only highlights the first search match in "ApplySearch".

    Best regards

  • Replied 29 October 2020, 12:29 am EST

    Hi Wolfgang,

    Thank you for appreciating. I agree with you meeting is close to impossible but good feedback would be a glass of beer for me ;-)

    >>One might consider it a bug the C1FlexGrid only highlights the first search match in "ApplySearch".
    We are discussing it with the developers and will get back to with the updates soon.
    [Internal Tracking ID: 23802]

    Prabhat Sharma.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels