2016-10-21 56 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

相關問題