Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
135
UltraLabel + CalcManager not working with money format
posted

The issue I have is that I need to format the label text to currency but using the calcmanager, it fails when the text is formated using Format(txtValue, "c"). I think that MaskEdit gets around this issue by having both a value property and a Text property. I guess I could use the Tag property as the value calculated and the text property as the format value? Not sure if this will work?

Any other ideas?

 

Using a MaskEdit is not an option since it needs to look like a label without appearance trickery. 

 

Any idea how I can format the label text but still use calcmanager?

 

I,ll take my answer off the air...lol

 

Thanks, -Joe

Parents
No Data
Reply
  • 135
    Verified Answer
    posted

    Got it working. 

     

    Solution was to use the Tag property to calculate via the CalcManager .PropertyName = "Tag" 

    One other issue was the sync between Tag and Text property. For this I simply had to override the base Tag property and set the text formating accordingly. Also added an event for custom formating and call it last to give custom handlers a crack at it.

     

    Public Class CurrencyLabel

        Public Delegate Sub TagChangedEventHandler(ByVal sender As ObjectByVal e As TagEventArgs)
        Public Event OnTagChanged As TagChangedEventHandler

        Public Sub New()
            InitializeComponent()
        End Sub

        Public Shadows Property Tag()
            Get
                Return MyBase.Tag
            End Get
            Set(ByVal value)
                MyBase.Tag = value
                MyBase.Text = Format(value, "c")
                Dim TE As New TagEventArgs(value)
                RaiseEvent OnTagChanged(Me, TE)
            End Set
        End Property

        Public Class TagEventArgs
            Inherits EventArgs

            Private _tag As Object
            Public Sub New(ByVal ptag As Object)
                _tag = ptag
            End Sub
            Public ReadOnly Property tag() As Object
                Get
                    Return _tag
                End Get
            End Property

        End Class

    End Class

Children
No Data