validating textbox in windows form applications

前端 未结 7 1708
北荒
北荒 2020-12-12 08:21

My scenario is:

Not allowing spaces at starting position of textbox after enter one or more characters text box allows spaces

Below not applicable to my sce

相关标签:
7条回答
  • 2020-12-12 08:53

    I believe that lazyDBA's answer is correct for your requirements, so with the message box something like:

    if (textBox1.Text.Length == 0)
    {
       if (e.Handler = (e.KeyChar == (char)Keys.Space))
       {
           MessageBox.Show("space not allowed!");
       }  
    }`
    
    0 讨论(0)
提交回复
热议问题