User2341
User2341

Reputation: 45

NumericUpDown maximum value linked to another textbox

is there a way for the maximum value of numericUpDown linked or depends on the value of textbox labeled AB?

for example the value of textbox labeled "AB" is 10, it automatically sets the maximum value of numericUpDown to 10.

enter image description here

Upvotes: 0

Views: 653

Answers (1)

Steve
Steve

Reputation: 216303

You can simply add an event handler for the Leave event and set the Maximum property of the NumericUpDown in that event

Sub AB_Leave(sender As Object, e As EventArgs)

    Dim value As Decimal
    ' Safety check, the user can type anything in the textbox, 
    ' we accept only a decimal number
    If Decimal.TryParse(AB.Text, value) Then
        numericUpDown1.Maximum = value
    End If
End Sub

Upvotes: 1

Related Questions