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

Underline does not work in WPF grid

Thread ID:





97896 Jan 18,2011 05:10 PM UTC Jan 26,2011 11:19 AM UTC WPF 5
Tags: GridControl
Ray Huger
Asked On January 18, 2011 05:10 PM UTC

In my GridQueryCellInfoEventHandler

I have the following code:

e.Style.Font.FontWeight = _headerStyle.Font.FontWeight;
e.Style.Font.FontStyle = _headerStyle.Font.FontStyle;
e.Style.Font.TextDecorations = _headerStyle.Font.TextDecorations;

FontWeight works. FontStyle works. TextDecorations does not work.

I've tried hard coding to:

e.Style.Font.TextDecorations = TextDecorations.Underline;

Still does not work.

Am I doing something wrong?

Manikandan [Syncfusion]
Replied On January 21, 2011 07:41 AM UTC

Hi Ray,

Thanks for using Syncfusion Products.

You can achieve your requirement by setting TextDecoration on loading the grid itself, instead of assigning it in QueryCellInfo. After applying the styles you have to call the InvalidateVisual to refresh the grid as follows,

Code snippet [C#]

We have developed a sample based on your requirement, Please download the sample in the following location.

Sample : http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=GridControls-1392950256.zip

Note : In the sample we have applied the TexDecoration in the Constructor itself.

Please let us know if have any queries.

Manikandan JR.

Ray Huger
Replied On January 21, 2011 07:13 PM UTC

Thank you for your response.

However, I do not understand why TextDecoration is handled separately from other style properties like FontWeight and Foreground.

I have a huge table and the Syncfusion Grid has the very important virtualization capabilty I need to style only the cells that come into view. The whole point of UNDERLINING is to give EMPHASIS to the occasional cells within a large population that have unusual values. So I have to be able to apply underlining just-in-time and selectively.

Your example does not do that.

Kamalakannan A [Syncfusion]
Replied On January 24, 2011 08:27 AM UTC

Hi Ray,

Thanks for your update.

The TextDecorations property is completely different from the FontWeight, FontStyle etc. The FontWeight, FontStyle properties are Enum property where the values can be assigned to the particular property directly. But the TextDecorations is a collection of IList where it acts as a complex property contains Location and Pen property in it. Hence an object should be created for this collection and only this can be added in the collection.

However you can use this property in the QueryCellInfo event as this QuerycellInfo event will draw the cells only which is visible inside the scroll viewer.

[Code Snippet] [C#]

grid.Model.QueryCellInfo += new Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventHandler(Model_QueryCellInfo);

void Model_QueryCellInfo(object sender, Syncfusion.Windows.Controls.Grid.GridQueryCellInfoEventArgs e)
grid.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].CellValue = string.Format("{0},{1}", e.Cell.RowIndex, e.Cell.ColumnIndex);
grid.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].Font.TextDecorations = new TextDecorationCollection();
grid.Model[e.Cell.RowIndex, e.Cell.ColumnIndex].Font.TextDecorations.Add(new TextDecoration { Location = TextDecorationLocation.Strikethrough, Pen = new Pen(Brushes.Red, 2) });


Please let us know if have any queries.


Ray Huger
Replied On January 24, 2011 02:46 PM UTC

I upgraded to and that enabled setting Underline in Model_QueryCellInfo.

Kamalakannan A [Syncfusion]
Replied On January 26, 2011 11:19 AM UTC

Hi Ray,

Thanks for your update.

Please let us know if have any queries.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the 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