I am building a **Windows Forms** application and want to prohibit the user from entering *spaces* and other *whitespaces* into the `TextBox`. I do not want to check it after sending the form with a message appearing "You entered a space" or something like that. I do not want to use this:

```
    protected override void OnKeyDown(KeyEventArgs e)

```

Because I would have to compare the key that was pressed with *all possible whitespaces*. 
Is there any way to set the `TextBox` to accept only characters which are *not whitespaces*?