Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9225969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:42:41+00:00 2026-06-18T04:42:41+00:00

I subclassed a textbox according to my needs by example from here On same

  • 0

I subclassed a textbox according to my needs by example from here

On same way I try to subclass NumericUpDown control to get selectAll functionality on them and to replace if point (“.”) char is pressed to comma (“,”) char to suit NumericUpDown control more suitable to my locale.

But I can’t do that because NumericUpDown haven’t a same properties like textbox has and I would like that both those controls behave at same way.

In my code two problems remains, SelectAll and SelectionLength :

Option Explicit On
Option Strict On

Public Class xNumericUpDown
Inherits NumericUpDown

Private alreadyFocused As Boolean

Protected Overrides Sub OnLeave(ByVal e As EventArgs)
    MyBase.OnLeave(e)

    Me.alreadyFocused = False

End Sub

Protected Overrides Sub OnGotFocus(ByVal e As EventArgs)
    MyBase.OnGotFocus(e)

    If MouseButtons = MouseButtons.None Then

        Me.SelectAll() ' HOW TO MAKE SELECTALL SUB FOR NUMERICUPDOWN?
        Me.alreadyFocused = True

    End If
End Sub

Protected Overrides Sub OnMouseUp(ByVal mevent As MouseEventArgs)
    MyBase.OnMouseUp(mevent)

    If Not Me.alreadyFocused AndAlso Me.SelectionLength = 0 Then ' HOW TO CHECK SELECTIONLENGTH FOR NUMERICUPDOWN?

        Me.alreadyFocused = True
        Me.SelectAll() ' HOW TO MAKE SELECTALL SUB FOR NUMERICUPDOWN?

    End If
End Sub

Protected Overrides Sub OnKeyPress(ByVal keyevent As KeyPressEventArgs)
    MyBase.OnKeyPress(keyevent)

    If keyevent.KeyChar = "." Then
        keyevent.KeyChar = CChar(",")
    End If
End Sub

End Class

Please help to get this working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:42:43+00:00Added an answer on June 18, 2026 at 4:42 am

    for checking the length and selecting all text try this :

    If Not Me.alreadyFocused AndAlso Me.Text.Length = 0 Then 'Though I suspect it should be <> 0
    
       Me.alreadyFocused = True
       Me.Select(0, Me.Text.Length)
    
    End If
    

    and for the char replacement, try this (untested) :

    If keyevent.KeyChar = "."c Then
          keyevent.Handled = True
          SendKeys.Send(",")
    End If
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating a text editor. My text-box control is a subclass of TextBox
I'm trying to draw a margin at 80 characters in my TextBox subclass. Here
I have subclassed a control in C# WinForms, and am custom drawing text in
I have subclassed a UITableViewCell and within this class I want to get it's
I have subclassed the RadioButtonList control in order to create a Control Adapter that
I have five text boxes that are subclassed views that cycle values from an
I have created a subclass of the TextBox class so that I can capture
I subclassed a UITextField and wish to get a method called when it becomes
There seems to be a problem with the ASP textbox control when set to
I subclassed View to get an View on which the user can draw with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.