如何在c#中的winfrom文本框中检查验证? [英] How can I check validation in winfrom text Box in c#?

查看:265
本文介绍了如何在c#中的winfrom文本框中检查验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c#中的winfrom文本框中检查验证?

How can I check validation in winfrom text Box in c#?

推荐答案

if (textBox1.Text.Trim() == "")
            {
                MessageBox.Show("Insert Your Message");
            }
            else if (textBox2.Text.Trim() == "")
            {
                MessageBox.Show("Insert Your Message");
            }


有两种方法,但是基本方法是处理TextChanged事件(如果要防止任何无效输入)或Validating事件(如果您想在用户完成操作后对其进行检查)

无论哪种情况,您都可以根据自己的条件检查Text属性.
There are a couple of ways, but the basic methods are to handle either the TextChanged event (if you want to prevent any invalid entry) or the Validating event (if you want to check it when the user is finished)

In either case, you can then check the Text property against your criteria.


这篇关于如何在c#中的winfrom文本框中检查验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆