Jul 25, 2016 05:06 PM
(This post was last modified: Jul 25, 2016 05:07 PM by tenalp eht kcah.)
Hi, when using no theme the following code works properly to only allow number input to textbox:
But when I use a theme with the exact same code (textBox1) replaced with proper name, it does not work and the user can input any character. How can I fix this?
Code
private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) &&
(e.KeyChar != '.'))
{
e.Handled = true;
}
// only allow one decimal point
if ((e.KeyChar == '.') && ((sender as TextBox).Text.IndexOf('.') > -1))
{
e.Handled = true;
}
}Code
this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(textBox1_KeyPress);But when I use a theme with the exact same code (textBox1) replaced with proper name, it does not work and the user can input any character. How can I fix this?



