We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the Foreground of Selected Row in the GridDataControl based on the ConditionalFormats?

When you set the GridDataControl.Foreground, it applies foreground to GridDataControl and the selected row is displayed based on the GridDataControl.StyleManager.RowAppearence.HighlightSelectionForeground.

When you want to set the same foreground to the non-selected rows and selected rows, you need to set the same foreground to the GridDataControl.Foreground and GridDataControl.StyleManager.RowAppearence.HighlightSelectionForeground properties as shown in the following code example.

When setting foreground to the specific cell based on the ConditionalFormats, the selected row foreground is based on the GridDataControl.StyleManager.RowAppearence.HighlightSelectionForeground instead of ConditionalFormats Foreground. You can overcome this problem by setting the e.Style.Foreground within PrepareRenderCell event conditionally.

The following code example shows how to set the foreground to the specific cell based on the ConditionalFormats.


The following code example shows how to set the e.Style.Foreground within the PrepareRenderCell event based on the condition.


By using the same way, you can set the Foreground to HoveringRecordCell with the help of the GridDataControl.StyleManager.RowAppearence.HoveringRecordCellForeground property in GridDataControl.

The following screenshot shows the output of the GridDataControl where the Foreground of Selected row is changed from its default color.


You can refer to the following sample links to change the foreground color for selected row in GridDataControl based on Conditional formats.

Sample link: ForegroundColorForSelectedRow_WPF

Article ID: Published Date: Last Revised Date: Platform: Control: .NET Framework:
3971 02/12/2015 07/10/2015 WPF GridDataControl 4.5
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Please sign in to access our KB

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon