写了1个小函数,可以限制文本框的输入,基本上是任意字符了.但是有点小问题啊
        public static char  TextLimit(char Keyin, string ListString, bool EditBasp)
        {
            string TextLimt;//要限制的字符串
            char KeyOut;//返回值
            if (EditBasp == true)//可以退格
            {
                TextLimt = ListString + (Char)8;
            }
            else
            {
                TextLimt = ListString.ToUpper(); 
            }
            int i;
            i = TextLimt.IndexOf(Keyin);
            if (i > 0)
            { KeyOut = Keyin; }
            else
            { 
//这里不知道要怎么处理了,就想如果是限制的字符,就不做任何事情
                //KeyOut ='' ;  这个写法错误
            }
            return KeyOut;
        }
//这是文本框的键盘事件
        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            e.KeyChar =TextLimit(e.KeyChar , "0123456789", true    );
        }
问题就是,如果我限制  "0123456789", 只能输入1-9 ,那个0也变成无法输入了



 
											





 
	    

 
	




