我有一些代碼,是爲了檢查某個字符的文本框,但由於某種原因,我有「KeyChar」和「已處理」的部分代碼的問題:文本框驗證表單
private void textBox5_Validating(object sender, CancelEventArgs e)
{
string allowedCharacterSet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890.\b\n";
if (allowedCharacterSet.Contains(e.KeyChar.ToString()))
{
if (e.KeyChar.ToString() == "."
&& textBox5.Text.Contains("."))
{
e.Handled = true;
}
}
else
{
e.Handled = true;
}
}
.............
Error 2 'System.ComponentModel.CancelEventArgs' does not contain a definition for 'KeyChar' and no extension method 'KeyChar' accepting a first argument of type 'System.ComponentModel.CancelEventArgs' could be found (are you missing a using directive or an assembly reference?) D:\test\Form1.cs 602 48 App
沒有物業類型上名爲CancelEventArgs KeyChar。 –
你爲什麼要問另一個問題,而不是修復你的原始問題:http://stackoverflow.com/questions/6414699/c-using-tryparseexact-with-windowsforms-textbox ?? –