I have a WinForm in C# with an NumericUpDown Control on it. I want the Control to change its value only after clicking on its up or down arrow, and to block the manual text entries, is there a property of NumericUpDown to do this, or any other way to implement?
numericUpDown.ReadOnly = true;
Please find below code which meets your requirement and might solve your issue:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new EventHandler(Form1_Load);
}
void Form1_Load(object sender, EventArgs e)
{
numericUpDown1.KeyDown+=new KeyEventHandler(numericUpDown1_KeyDown);
}
void numericUpDown1_KeyDown(object sender, KeyEventArgs e)
{
e.SuppressKeyPress = true;
return;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With