Hello,
I have read the post below and I have a similar issue but I don't know how to get around it. The users are expecting to see 0 in a calculated field but are seeing 0.01... this is -0.00547442024253542D rounded to 2 decimal places... I understand that this is because I am using decimals and the calc manager uses double ... but I'm not sure at what point to round this so it shows 0.... if i try to update the cell in the before or after row edit template displayed event for example the value gets changed by the calcmanager afterwards. Is there a place I can change the value after the calc manager has calc'd the cell but before it is displayed?
http://forums.infragistics.com/forums/p/5338/24183.aspx
regards
Darren
Hi Darren,
There are a couple of bad assumptions here. The first one is this:
If (Not (TypeOf (parent) Is CellUIElement)) Then Return
You are assuming that the TextUIElement is a direct child of the CellUIElement, but that is not usually the case. You should try to make your CreationFilter account for as many variations as possible.
Here's a better, and simpler way:
Public Sub AfterCreateChildElements(ByVal parent As Infragistics.Win.UIElement) Implements Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements Dim cell As UltraGridCell = CType(parent.GetContext(GetType(UltraGridCell)), UltraGridCell) If cell Is Nothing Then Return Dim column As UltraGridColumn = cell.Column ' getting the uielement to see if can change text Dim tTextUIElement As TextUIElement = CType(parent.GetDescendant(GetType(TextUIElement)), TextUIElement) If tTextUIElement Is Nothing Then Return If column.Key = "value_9" Then ' tried it both ways, setting the text property of uielement or cell value tTextUIElement.Text = "999" End If End Sub
Hi Mike, I am kind of stuck..... I can kind of get it working but not on formula columns it seems.... here is the code in case I'm taking the wrong approach....
Public Sub AfterCreateChildElements(ByVal parent As Infragistics.Win.UIElement) Implements
Infragistics.Win.IUIElementCreationFilter.AfterCreateChildElements
Dim column As UltraGridColumn
' get the associated column
column =
CType(parent.GetContext(GetType(UltraGridColumn)), UltraGridColumn)
Dim cell As UltraGridCell = CType(parent.GetContext(GetType(UltraGridCell)), UltraGridCell)
' getting the uielement to see if can change text
Dim tTextUIElement As TextUIElement = CType(parent.GetDescendant(GetType(TextUIElement)), TextUIElement)
If column Is Nothing Then Return
If column.Key = "value_9" Then
' tried it both ways, setting the text property of uielement or cell value
tTextUIElement.Text = "999"
' and by setting the cell value
cell.value=999
EndIf
It seems like it changes the value if the field is not a formula? I'm not sure if I should be using drawfilter for this....
EndSub
If you are going to try the CreationFilter, I recommend that you get the Infragistics UIElementViewer Utility.
It will be a huge help. Let me know if you get stuck of have any questions.
Thanks Mike, the Creation filter seems the way to go, I haven't used them before but I'll check out the documentation.
You could change the display in any number of ways. The simplest way is to hide the real column with the formula in it and add an unbound column in it's place. Then you just use the InitializeRow event to get the value from the real column, format it however you want, and set the value of the unbound cell in the same row to display to the user.
Another option would be to use a DrawFilter or a CreationFilter to change the display text of the cell without affecting the underlying value.
You could also do the same thing using a DataFilter, but this would be the most complicated option.