遮罩的内容文本框 [英] masked content text box

查看:82
本文介绍了遮罩的内容文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助,
如何阅读maskedtextbox的一部分?例如,如果用户输入的数据是"123-456-789-444",我想将第二个被屏蔽的项("456")分配给label1.text
任何帮助将不胜感激.

Please help,
How can I read a part of a maskedtextbox? for example if the data entered by the user is "123-456-789-444", I would like to assign the second masked item ("456") to label1.text
Any help will be appreciated.

推荐答案

您可以通过String.Split()方法来实现.
这是为您提供的解决方案.

You can do it by String.Split() method.
Here is the solution for you.

string maskStr = "123-456-789-444";
        int count = maskStr.Split('-').Length - 1;
        string[] masks = new string[count];
        masks = maskStr.Split('-');
        label1.Text = masks[1];


这篇关于遮罩的内容文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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