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

PrepareViewStyleInfo in 4.2.0.60 not working the same way as 4.1.0.50

I''m currently contemplating an upgrade from 4.1.0.50 to 4.2.0.60 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 4.1.0.50 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 4.2.0.60?

issue11.zip

4 Replies

AD Administrator Syncfusion Team 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

Or.

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

Me.gridControl1.RefreshRange(GridRangeInfo.Cell(3,3))

Thanks,
Haneef


AD Administrator Syncfusion Team September 15, 2006 12:48 PM UTC

Hi Amit,

We have some performance problem in Essential studio 4.1.0.50. So a change has been made in GridFormulacell.cs under GetFormattedText method after Essentail Studio 4.1.0.50. 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...
if(saveTag)
{
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.
http://www.syncfusion.com/Support/user/uploads/issue11_da9e4fec.zip

Let me know if you are looking something different

Thanks,
Haneef


AD Administrator Syncfusion Team 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?

Thanks.


AD Administrator Syncfusion Team 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.
http://www.syncfusion.com/Support/user/uploads/27964_b0179a9.zip

Thanks for your patience.

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon