带有特殊输入的文本框 [英] textbox with special inputs

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

问题描述

如何给一个文本框只接受'abhijeet'这个字符串。

解决方案

你好,



你正在使用WinForm所以你可以这样做:



验证活动的样本



private void textBox1_Validating(object sender,CancelEventArgs e){

if(textBox1.Text!=something)

e.Cancel =真的;

}





您可以使用ErrorProvider 可视化验证


如果这是密码输入方案:使用带有PasswordChar的TextBox属性设置适当:[ ^ 。根据您的要求,您可能还希望设置TextBox MaxLength和CharacterCasing属性。


您好Abhijeet,



如果你想要文本框只接受'abhijeet'然后你应该使用



 如果 (Textbox1.Text ==   abhijeet
{
// 如果相同,请转到此部分
}
else
{
// 如果不是
}





  if (Textbox1.Text.Equals(  abhijeet))
{
// 如果相同,请转到此部分
}
else
{
// 如果不是
}来这里



希望这会对你有所帮助。



问候,

RK


how to give that a textbox only accept 'abhijeet' this string.

解决方案

Hi,

You're using WinForm so You can do something like this:

Sample for Validating Event

private void textBox1_Validating(object sender, CancelEventArgs e){
if (textBox1.Text != "something")
e.Cancel = true;
}


You can use ErrorProvider to visualize validation


If this is a password-entry scenario: use a TextBox with the PasswordChar Property set appropriately: [^]. Depending on your requirements you may also wish to set the TextBox MaxLength and CharacterCasing properties.


Hi Abhijeet,

If you want textbox to accept only 'abhijeet' then you should use

if (Textbox1.Text == "abhijeet")
{
 //Come to this section if same
}
else
{
 //Comes here if its not
}


or

if (Textbox1.Text.Equals("abhijeet"))
{
 //Come to this section if same
}
else
{
 //Comes here if its not
}



Hope this helps you a bit.

Regards,
RK


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

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