How to do it...

  1. Start by adding a new Windows forms project to your solution.
  2. Call the project winformSecure and click on the OK button.
  3. In the Toolbox, search for the TextBox control and add it to your form.
  4. Lastly, add a button control to your form. You can resize this form, however you like to look more like a login form:
  1. With the textbox control selected on the Windows forms, open up the Properties panel and click on the Events button (it looks like a lightning bolt). In the Key group, double-click on the KeyPress event to create the handler in the code behind:

The code that is created for you is the KeyPress event handler for the ...

Get C# 7 and .NET Core Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.