最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vb.net - NumericUpDown with UpdateEditText() - Stack Overflow

programmeradmin3浏览0评论

I need to set two numericupdown controls to set two numbers with the following format:

  1. One with 000001 format
  2. The other with 001 format

I've found the UpdateTextEdit() control on MS Support page but I can't understand how to use it on vb.NET.

I need to set two numericupdown controls to set two numbers with the following format:

  1. One with 000001 format
  2. The other with 001 format

I've found the UpdateTextEdit() control on MS Support page but I can't understand how to use it on vb.NET.

Share Improve this question asked Jan 20 at 14:29 NicolaNicola 234 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

You have to derive your own Control from NumericUpDown and then override UpdateEditText(). This method is Protected. This means that it is only visible in derived classes (and in the original class of course).

In the following example I also added a Format property which appears in the properties window under Appearance (after you have compiled the code for the first time).

This new control also appears in the Toolbox and you can drag and drop it to your forms like a normal NumericUpDown.

Imports System.ComponentModel
Imports System.Windows.Forms

Public Class FormattedNumericUpDown
    Inherits NumericUpDown

    Private _format As String

    <Category("Appearance")>
    Public Property Format As String
        Get
            Return _format
        End Get
        Set(value As String)
            _format = value
            UpdateEditText()
        End Set
    End Property

    Protected Overrides Sub UpdateEditText()
        Text = Value.ToString(_format)
    End Sub
End Class

发布评论

评论列表(0)

  1. 暂无评论