Clearing NumericUpDown

前端 未结 3 1192
别那么骄傲
别那么骄傲 2021-01-29 12:39

My problem with NumericUpDown control is when the user selects a value from NumericUpDown And unchecks the checkBox1 and clicks the Save button, the value of NumericUpDown not c

3条回答
  •  盖世英雄少女心
    2021-01-29 13:06

    NumericUpDown does not contain string. It has value as numbers. So it should be:

    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged
          If CheckBox1.Checked = False Then
                AgeNumericUpDown.Value = 0
          End If
    End Sub
    

    EDIT:

    Check this out then if you don't want the value to be zero, but empty!

     Private Sub BttnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BttnSave.Click
        If AgeNumericUpDown.Value <> 0 Then
            AgeNumericUpDown.Controls(1).Text = ""
        End If
    End Sub
    

提交回复
热议问题