我创建了一个必须在其中输入货币值的文本框,但现在我无法在文本框中输入 .(dot) 以获取十进制值。我已经在 Text_changed 事件中编写了代码。编码
int cursorLocation = ((TextBox)(sender)).SelectionStart;
string inputval = ((TextBox)sender).Text;
inputval = inputval.Replace("*", "");
inputval = inputval.Replace("#", "");
inputval = inputval.Replace(",", "");
inputval = inputval.Replace(" ", "");
inputval = inputval.Replace("-", "");
Decimal inputval1 = Convert.ToDecimal(inputval);
((TextBox)sender).Text = inputval1.ToString("###,###");
cursorLocation = ((TextBox)(sender)).Text.Length;
//((TextBox)sender).Text = inputval;
((TextBox)(sender)).SelectionStart = cursorLocation;