我正在使用下面的代码,在测试时,textBoxes将允许输入数字,但您必须输入完整的数字,然后返回箭头输入小数。否则光标会跳到第一个数字的前面,并且不允许输入小数。我还想先让$输入。
我是否可以自定义此textBox以执行这些功能以允许计算在下面给出正确的功能?
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
{
//Adding ToolTip
ToolTipService.SetToolTip(textBox1, "Enter Price, numbers first, then arrow back to add decimal.");
if (Double.TryParse(textBox1.Text, out value1))
{
textBox1.Text = value1.ToString();
}
textBox69.Text = value69.ToString();
if (textBox1.Text == null || textBox1.Text == "") value1 = 0;
{
textBox1.Text = value1.ToString();
if (textBox1.Text.EndsWith(".97") == true)
{
value20 = 0; value36 = 0; value69 = 0;
textBox20.Text = value20.ToString();
textBox36.Text = value36.ToString();
textBox69.Text = value69.ToString();
}
if (textBox1.Text.EndsWith("1") || textBox1.Text.EndsWith("2") || textBox1.Text.EndsWith("3") || textBox1.Text.EndsWith("4") || textBox1.Text.EndsWith("5") || textBox1.Text.EndsWith("6") || textBox1.Text.EndsWith("8") || textBox1.Text.EndsWith("9") || textBox1.Text.EndsWith("0") == true && (value1 < 100.00))
{
value69 = 1;
textBox69.Text = value69.ToString();
}
if (value1 > 100.01 && value1 < 149.99)
value69 = 2;
textBox69.Text = value69.ToString();
}
}