空白文本框 [英] Blank TextBox
本文介绍了空白文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我在C#Windows应用程序中有3个TextBox
es和1个Button
.
如果用户单击Button
,则我检查是否有任何TextBox
为空,然后使用
MessageBox.Show("You cannot use a blank TextBox")
,并在自动将焦点设置为空白后TextBox
我这样做,但是我没有将焦点放在空白TextBox
中.那我该怎么办?
请帮帮我
在此先感谢
[修改:删除每个单词的首字母大写,并尝试使其更具可读性.]
Hi
I have three TextBox
es in C# Windows Application and one Button
.
If user clicks a Button
then I check if any TextBox
is empty, then I use
MessageBox.Show("You cannot use a blank TextBox")
and after automatic set focus in blank TextBox
I do this but I do not set focus in blank TextBox
. So what do I need to do?
Please help me
Thanks in advance
[Modified: removed capitalization on the first letter of every word and tried to make it more readable.]
推荐答案
this.textBox1.Focus();
您真的需要显示一个消息框吗?
消息框的目的仅仅是传达错误/警告,如果是,那么我认为您可以使用错误提供程序控件.
尝试以下链接:
Do you really need to show a messagebox.
Is the purpose of messagebox is just to convey the error/warning, if Yes then I think you can use errorprovider control.
Try these links:
- http://www.c-sharpcorner.com/UploadFile/DipalChoksi/UsingErrorProviderContolinWindowsFormsandCSharp11242005010829AM/UsingErrorProviderContolinWindowsFormsandCSharp.aspx[^]
- http://www.developerfusion.com/code/4445/userfriendly-validation-using-errorprovider/[^]
这篇关于空白文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文