Change backcolor of results after search

1 Answer 87 Views
GridView
R.D. Henry and Co.
Top achievements
Rank 2
Iron
Iron
Iron
R.D. Henry and Co. asked on 21 Mar 2022, 08:15 PM

Using Visual Studio 2019 and Winforms.  I have a hierarchical radgridview with my own search function.  How can I change the yellow color when the search has found what was requested?  I've been working with Visual Style Builder to try to find this but have had no luck.  Thanks.

 

R.D. Henry and Co.
Top achievements
Rank 2
Iron
Iron
Iron
commented on 22 Mar 2022, 09:17 PM

Anyone?

1 Answer, 1 is accepted

Sort by
0
Accepted
Dinko | Tech Support Engineer
Telerik team
answered on 23 Mar 2022, 01:02 PM

Hi Curtis Hines

Thank you for the provided images.

You can try setting the radGridView1.TableElement.SearchHighlightColor property to change the color of the found match results. You can check the Search Row help article where this is mentioned. 

Give this property a try and let me know how it goes.

Regards,
Dinko
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

R.D. Henry and Co.
Top achievements
Rank 2
Iron
Iron
Iron
commented on 23 Mar 2022, 03:44 PM

Thanks.  That changed the highlight for the parent but not the child.  How do I change the background color on the child?
Dinko | Tech Support Engineer
Telerik team
commented on 24 Mar 2022, 08:53 AM

In this case, you can subscribe to the ViewCellFormatting event handler and check if the CellElement property from the event arguments is GridDetailViewCellElement. If yes, set the GridDetailViewCellElement.ChildTableElement.SearchHighlightColor property to the desired color.

private void GridOrders_ViewCellFormatting(object sender, CellFormattingEventArgs e)
{
    if(e.CellElement is GridDetailViewCellElement detailViewCellElement)
    {
        detailViewCellElement.ChildTableElement.SearchHighlightColor = Color.Red;
    }    
}

R.D. Henry and Co.
Top achievements
Rank 2
Iron
Iron
Iron
commented on 25 Mar 2022, 02:32 PM

That worked great. Thanks.

code converted to vb:


        If (TypeOf e.CellElement Is GridDetailViewCellElement) Then
            Dim cell As GridDetailViewCellElement = CType(e.CellElement, GridDetailViewCellElement)
            cell.ChildTableElement.SearchHighlightColor = Color.LightGreen
        End If

Tags
GridView
Asked by
R.D. Henry and Co.
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or