2016-10-21 30 views

回答

1

可以简单地添加的事件处理程序Leave事件并设置在这种情况下NumericUpDown的最大属性

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 
+0

它的工作原理!非常感谢你的答案,现在我的问题是,如果我在NumericUpDown上输入一个比AB.Text的值更大的数字,应该会出现消息错误。 – User2341

+0

像这样:If numberUpDown.value> AB.Text MsgBox(“无效数据”,MsgBoxStyle.Critical,“库存系统”我不知道为什么错误不显示,它只会自动调整numericUpDown的值等于AB.Text值 – User2341

+0

我不知道有什么东西可以用在这种情况下。可能你应该直接使用键盘事件来解释这个答案http://stackoverflow.com/questions/17369670/how-to-validate-numericupdown-当然,关于复制/粘贴操作呢?正如你所看到的,如果没有控制器本身的直接支持,就不容易达到这种控制水平。另一种可能是控制子类,这是另一种蠕虫病毒,你应该在下一步之前加重执行成本。 – Steve

相关问题