I have a grid where I've set the NullText to ***No Value Set*** and I also have a TemplateAddRow at the bottom, which I'd like to have a TemplateAddRowPrompt for. Unfortunately having both NullText and the Add Row Prompt doesn't seem to work very well as both lots of text are shown on top of each other!
Ideally I'd like to turn off the NullText for the Template Add Row, that way the prompt would be shown and the NullText would only start displaying once the user starts adding a row. Is this possible?
I'm using 2010 vol 1
Regards
Alex McMahon
Totally legit; solved my problem the easy way. Thanks, Mike! For those interested in the VB version: here 'tis:
' =================================================== CLASS ITemplateAddRowNullTextOverrideDrawFilter ================================================================= Public Class ITemplateAddRowNullTextOverrideDrawFilter Implements IUIElementDrawFilter
Public Function DrawElement(drawPhase As DrawPhase, ByRef drawParams As UIElementDrawParams) As Boolean Implements IUIElementDrawFilter.DrawElement
' The only time we will ever get in there is for the BeforeDrawForeGround phase ' of an EditorWithTextDisplayTextUIElement in a TemplateAddRow where there is NullText applied. Return True
End Function
Public Function GetPhasesToFilter(ByRef drawParams As UIElementDrawParams) As DrawPhase Implements IUIElementDrawFilter.GetPhasesToFilter
' Look specifically for an EditorWithTextDisplayTextUIElement If (TypeOf (drawParams.Element) Is EditorWithTextDisplayTextUIElement) Then
Dim cell As UltraGridCell = drawParams.Element.GetContext(GetType(UltraGridCell))
' if this is is a templateaddrow cell with a null value, return the BeforeDrawForeGroundPhase; this will prevent drawing the foreground, ' which, in this case, is the NullText we don't want to see If cell IsNot Nothing _ AndAlso String.IsNullOrEmpty(cell.Column.NullText) = False _ AndAlso cell.Row.IsTemplateAddRow _ AndAlso (cell.Value Is Nothing OrElse IsDBNull(cell.Value)) Then
Return DrawPhase.BeforeDrawForeground
End If
' In all other case, return none, so the DrawFilter does nothing Return DrawPhase.None
End Class
Hi Alex,
I played around with this a little, and the only way I could find to get it to work was to use a DrawFilter:
public class MyDrawFilter : IUIElementDrawFilter { #region IUIElementDrawFilter Members bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { // The only time we will ever get in there is for the BeforeDrawForeGround phase // of an EditorWithTextDisplayTextUIElement in a TemplateAddRow where there is // NullText applied. return true; } DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams) { // Watch for an EditorWithTextDisplayTextUIElement if (drawParams.Element is EditorWithTextDisplayTextUIElement) { // Get the cell. UltraGridCell cell = drawParams.Element.GetContext(typeof(UltraGridCell)) as UltraGridCell; // If the cell is not null, and it's in the TemplateAddRow, and there's // a NullText applied to it, return the BeforeDrawForeGround phase. if (cell != null && !string.IsNullOrEmpty(cell.Column.NullText) && cell.Row.IsTemplateAddRow && (cell.Value is DBNull || cell.Value == null)) { return DrawPhase.BeforeDrawForeground; } } // Return None so the DrawFilter does nothing in any other case. return DrawPhase.None; } #endregion }