title: Preventing a special character input c#
body: <p>I am trying to stop user from entering a space key in text field. I have this code.</p>
  
  <pre><code>private void FirstNameBox_KeyDown(object sender, KeyEventArgs e)
          {
              //////////MessageBox.Show(e.KeyValue.ToString());
              //Now check to see if the key pressed is a space
              if ((e.KeyValue == 32))
              {
                  MessageBox.Show("Please Enter only first name.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                  //Stop the key registering
                  e.Handled = true;
                  e.SuppressKeyPress = true;
              }
              else
              {
                  //allow enter
              }
          }
  </code></pre>
  
  <p>Where 32 is the key value of Space Button. But this is not working now for me. I've use this code in past working perfectly with numeric entries only... trying it for space but not working. Any ideas??</p>