-1

i am use vb.net to make an application how i delete numeric up down value after select value from it when i try this code i receive error (Conversion from string "" to type 'Decimal' is not valid.)

Public Class FormAdd


Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.StudenttableBindingSource.AddNew()
End Sub

Private Sub BttnSave_Click(sender As Object, e As EventArgs) Handles BttnSave.Click

    Me.StudenttableBindingSource.EndEdit()
    Me.StudenttableTableAdapter.Update(Me.StudentDataSet.studenttable)
    Me.StudenttableTableAdapter.Fill(Me.StudentDataSet.studenttable)
    MsgBox(" Student Saveed", MsgBoxStyle.Information)
    Me.StudenttableTableAdapter.Fill(Main.StudentDataSet.studenttable)
    Me.Close()

End Sub

Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBox1.CheckedChanged

    If CheckBox1.Checked = False Then

        AgeNumericUpDown.Value = ""


    End If
End Sub

: i want to delete value not text

user3319402
  • 1
  • 1
  • 3

2 Answers2

0

I don't think you can do this using the default NumericUpDown control. The Value property needs an integer value, so you can't put a string value like "".Some 3rd party controls have this feature. You just set it to nothing. The closest you can do with the default control is... If you want to set it to nothing, you can just change the ForeColor property of the control so the user won't see any value because the color of the text blends in with the background, but it's still there.

NumericUpDown1.ForeColor = Color.Transparent

Upon entering a new value... Change the color again to black...

NumericUpDown1.ForeColor = Color.Black
chris_techno25
  • 2,401
  • 5
  • 20
  • 32
0

As far as i remember NumericUpDown control is not like a combobox that you can be able to removes item/s from the list.

The NumericUpDown control purpose is to increment/decrement the numeric value of the text area by the value specified in the increment property.

If you want to skip the next value just use ValueChanged event and check if it is already in used and then increment/decrement the value again by the value specified in the increment property.

Or if the list is not too large and in acceptable number of list, then you can use combobox instead.

Jade
  • 2,972
  • 1
  • 11
  • 9