2 Replies - 284 Views - Last Post: 17 October 2017 - 07:05 AM Rate Topic: -----

#1 mtnerd594  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-May 16

Custom TextBox Class

Posted 16 October 2017 - 08:17 PM

I am trying to create a custom textbox class that would add a '$' when focus is lost and then remove it when it comes into focus. I have tried several different ways. There are also other items that will be added to make it a unique textbox.

Public Class CurrTextBox
    Inherits DecTextBox

    Private Shadows Sub OnLostFocus(e As EventArgs)

        If Text.StartsWith("$") Then

            strText = Text.Substring(Text.Length, Text.Length - 1)

        Else

            strText = Text

        End If

    End Sub

    Private Shadows Sub OnGotFocus(e As EventArgs)

        Text = "$" & strText

    End Sub

End Class


The code compiles with no errors, but the Focus Events never fire. I would appreciate any input.

Thanks!

Is This A Good Question/Topic? 0
  • +

Replies To: Custom TextBox Class

#2 maceysoftware  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 348
  • View blog
  • Posts: 1,494
  • Joined: 07-September 13

Re: Custom TextBox Class

Posted 17 October 2017 - 01:37 AM

Instead of shadowing the events, override the events, remember to include the MyBase.OnLostFocus call so the base implementation of the event is still called.
Was This Post Helpful? 1
  • +
  • -

#3 mtnerd594  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-May 16

Re: Custom TextBox Class

Posted 17 October 2017 - 07:05 AM

Thank you! I figured it out just before you posted this, but thanks so much for your response!!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1