Search code examples
vb.netwinformsnumericupdown

Is their any CharacterUpDown Control in vb.net


In VB Win-forms Application a NumericUpDown Control is used for only to scroll numbers. Its definition is:

The Windows Forms NumericUpDown control looks like a combination of a text box and a pair of arrows that the user can click to adjust a value. The control displays and sets a single numeric value from a list of choices. As Shown here.

I want to use strings instead of numeric values. For example, Grades: "A","B","C", etc. I think I will need to use UserContorl to code another custom "StringUpDown" Control.


Solution

  • You can't add String values to Numeric Drop down. instead for this you can use DomainUpDown here is the code to place a DomainUpDown in your form that contains A - Z characters

        Dim domainUpDown1 As DomainUpDown
        domainUpDown1 = New System.Windows.Forms.DomainUpDown()
        For i As Integer = 65 To 90
            domainUpDown1.Items.Add(Chr(i))
        Next
        Controls.Add(domainUpDown1)
    

    Note : This control is available in Tool box also