在Textbox的輸入中﹐我們常常需要控制輸入的類型﹐比如說只能輸入數字﹐當然實現的方法很多﹐我總結了一下我做過的一些項目﹐我常會使用以下這三種﹕1﹑使用Try...Catch private static bool IsNumeric(string itemValue,int intFLag) } 2﹑使用正則表達式 using System.Text.RegularExpressions; private static bool IsNumeric(string itemValue) 3﹑判斷輸入的keyCode public static bool IsNumeric(System.Windows.Forms.KeyPressEventArgs e) } 相关文章: