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

PrepareViewStyleInfo in not working the same way as

Thread ID:





48998 Sep 7,2006 07:11 PM UTC Sep 26,2006 10:08 AM UTC WinForms 4
Tags: GridControl
Administrator [Syncfusion]
Asked On September 7, 2006 07:11 PM UTC

I''m currently contemplating an upgrade from to and here is an issue I''m having to do with a change in the way things work:
-Run the attached sample
-Press the "number" button, the value in cell A1 is set to the number 123
-The value in cell C3 recalculates but the textcolor does not become red as it should. To make it red, you have to force a refresh of that cell.
-Press the "text" button. C3 recalculates but now the text color is black as it should be.

If you run the sample under you will notice that as soon as you press the "number" button, C3 recalculates and the text becomes red.
How can I get the same old functionality in


Administrator [Syncfusion]
Replied On September 8, 2006 07:13 AM UTC

Hi Amit,

Instead of using the FormulaTag.Text to get the Formatted text, use the FormattedText property of the cell in a grid.

If Integer.TryParse(style.FormattedText, value) = True Then
style.TextColor = Color.Red
End If


Try refreshing the cell using the RefreshRange method in Number button click event..



Administrator [Syncfusion]
Replied On September 15, 2006 12:48 PM UTC

Hi Amit,

We have some performance problem in Essential studio So a change has been made in GridFormulacell.cs under GetFormattedText method after Essentail Studio It causes some refreshing problem in Essentail 4.2. Below is a code snippet changes in 4.2(Line 607).

//Modified Code....For performance reason...
bool b = this.Grid.IgnoreReadOnly;
this.Grid.IgnoreReadOnly = true;

// SH: Change this code from calling
// this.Grid[id.RowIndex, id.ColIndex].FormulaTag = tag;
// to use SetCellInfo instead.

GridStyleInfo style2 = new GridStyleInfo();
style2.FormulaTag = tag;
this.Grid.SetCellInfo(id.RowIndex, id.ColIndex, style2, StyleModifyType.Override);

// If you set .FormulaTag directly on a cell it will cause ChangeCells being
// called which then triggers a Invalidate call. This could cause CPU usage
// to spike to 100% because the Invalidate call will cause the cell to be repainted
// and in the Repaint call GetFormattedText is called which then restarts the
// whole process again. See defect 1596.
// I see .FormulaTag being set directly in other places too. This should be reviewed
// on a case to case basis.

this.Grid.IgnoreReadOnly = b;

So you can use FormattedText property to get the Formatted text in a ForumlaCell. Below is a code snippet.

Private Sub GridControl1_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles GridControl1.PrepareViewStyleInfo

//Instead of using the FormulaTag to get the Formatted text, use the FormattedText property of the cell in a grid
Dim style As GridStyleInfo = e.Style
If style.CellType = "FormulaCell" Then
Dim value As Integer
If Integer.TryParse(style.FormattedText, value) = True Then
style.TextColor = Color.Red
End If
End If
End Sub

Here is a modified sample.

Let me know if you are looking something different


Administrator [Syncfusion]
Replied On September 22, 2006 09:02 PM UTC

The workaround does not work if the style.Format property is set to an actual numeric format. With the numeric format set, the string returned from style.FormattedText could be transformed in any number of ways and will not necessarily be parsable as an integer.

Any suggestions?


Administrator [Syncfusion]
Replied On September 26, 2006 10:08 AM UTC

Hi Amit,

Sorry for the inconvenience caused.

This problem has been resolved in Essentail studio 4.3. You could get this working by handling the SaveCellInfo event in Essentail Studio 4.2. Below is a code snippet

Private Sub GridControl1_SaveCellInfo(ByVal sender As Object, ByVal e As Syncfusion.Windows.Forms.Grid.GridSaveCellInfoEventArgs) Handles GridControl1.SaveCellInfo
If e.Style.CellType = "FormulaCell" AndAlso e.Style.FormulaTag Is Nothing Or ( _
e.Style.Text <> Me.GridControl1(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex).Text) Then
Me.GridControl1.RefreshRange(GridRangeInfo.Cell(e.Style.CellIdentity.RowIndex, e.Style.CellIdentity.ColIndex))
End If
End Sub

Here is a sample.

Thanks for your patience.

Best Regards,


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