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. Image for the cookie policy date
close icon

Underline does not work in WPF grid

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?


5 Replies

MA Manikandan Syncfusion Team 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#]
Grid.Model.InvalidateVisual(true)

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.

Thanks,
Manikandan JR.






RH Ray Huger 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.



KA Kamalakannan A Syncfusion Team 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.

Thanks,
Kamal.




RH Ray Huger January 24, 2011 02:46 PM UTC

I upgraded to 8.4.0.10 and that enabled setting Underline in Model_QueryCellInfo.



KA Kamalakannan A Syncfusion Team January 26, 2011 11:19 AM UTC

Hi Ray,

Thanks for your update.

Please let us know if have any queries.

Regards,
Kamal.



Loader.
Live Chat Icon For mobile
Up arrow icon