在另一个文本框中显示一个文本框的后4位数字 [英] Displaying last 4 digits of a textbox in another textbox
本文介绍了在另一个文本框中显示一个文本框的后4位数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的大家,
我有两个文本框.我想使用第一文本框的textchanged事件将第一文本框的后4位显示到第二文本框...
例如:如果我在第一个文本框中输入4566456767,则应该在第二个文本框中显示6767.
请任何人建议我该怎么做..
问候,
Raj Bangalore
Hi Dear All,
I have two textboxes.. I want to display the last 4 digits of 1st textbox into 2nd textbox using the textchanged event of 1st textbox...
Ex: If I enter 4566456767 in 1st textbox, then 6767 should be displayed in 2nd textbox..
Please any one suggest me how to do this..
Regards,
Raj Bangalore
推荐答案
您将 ^ ]事件,则可以使用 SubString [ ^ ]以获得后4位数字.例如:
You wire up the TextChanged[^] event and you can use SubString[^] to get the last 4 digits. For example:
private void textBox1_TextChanged(object sender, EventArgs e) {
if (textBox1.Text.Length >= 4) {
textBox2.Text = textBox1.Text.Substring(textBox1.Text.Length - 4);
}
}
iam给您示例
试试这个
字符串str ="HelloWorld";
TextBox1.Text = str.Substring(str.Length-4);
iam giving you example
try this
string str = "HelloWorld";
TextBox1.Text=str.Substring(str.Length - 4);
这篇关于在另一个文本框中显示一个文本框的后4位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文