How to make a numerical button edit

Hello everyone.
How do I make a button edit accept numbers only? Is there any way you can do this? If possible give an example.
Ulisses

1 Reply

VR Vijayalakshmi Roopkumar Syncfusion Team January 2, 2018 05:40 PM UTC

Hi Ulisses,

Thank you for contacting Syncfusion Support

To restrict the ButtonEdit to allow only numbers, you can handle the KeyPress event of TextBox element of ButtonEdit as shows in the following code example. 

 
//Invoke the KeyPress event 
this.buttonEdit1.TextBox.KeyPress += TextBox_KeyPress; 
 
private void TextBox_KeyPress(object sender, KeyPressEventArgs e) 
{ 
if (char.IsDigit(e.KeyChar)) 
{ 
e.Handled = false; 
} 
else 
{ 
e.Handled = true; 
MessageBox.Show("Allows Only Numbers "); 
} 
 
} 
 

We have prepared the sample for the same,you can download it from the following location:

Sample: http://www.syncfusion.com/downloads/support/forum/135246/ze/ButtonEdit_Sample94253938 

Please try this solution and let us know if it is helpful

Regards,
Vijayalakshmi V.R. 


Loader.
Up arrow icon