检查空文本框或变量,然后分配 [英] Check for empty textbox or variable and next assign
本文介绍了检查空文本框或变量,然后分配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的;
1.如何检查空文本框或变量?
你下次如何分配
1.该空文本框的当前日期?
2.将文本框的值分配给另一个文本框
谢谢
Dear all;
1.How do you check for an empty textbox or variable?
How do you next assign
1. The current date to that empty textbox?
2. assign the value of a textbox to another textbox
Thanks
推荐答案
1.要检查值是否为空,您可以使用文本
属性:
1.To check if the value is empty you could useText
property:
if(texbox.Text.Length == 0)
2.将 textbox1
的值分配给 texbox2
:
2.To assign the value from textbox1
to texbox2
:
textbox2.Text = texbox1.Text;
3.将当前日期分配给文本框:
3.To assign the current date to a textbox:
textbox1.Text = DateTime.Now.ToShortDateString();
if (TextBox1.Text.Trim().Length == 0) {// Check Empty
DateTime today = DateTime.Today; //Get Today
TextBox1.Text=dateTime.ToString("dd/MM/yyyy");//Set Today to text box
TextBox2.Text = TextBox1.Text;//Set text box 1 value to Textbox 2
}
这篇关于检查空文本框或变量,然后分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文