The Source Code Library
Example for Windows Application
The following example creates a C# windows Form application with three text boxes and two button controls. When user enters two numbers in to first two text boxes and clicks on first button then sum has to be calculated for those two numbers and display the result in third text box.
1. Create a windows application and design the form as follows.
Open Visual Studio ->File -> New Project ->Visual C#-> select Windows Forms Application
Give the name of the application and click on OK
2. Set the following properties for the controls on the form.
TextBox1 Name : TxtNum1
TextBox2 Name : TxtNum2
TextBox3 Name : TxtResult
Button1 Name : BtnSum
Text : Sum
Button2 Name : BtnClose
Text : Close
3. Double click on the sum button and write the following code in the click event of that button to calculate sum and display the result in result textbox
TxtResult.Text = (
4. Double click on close button and write the following code in the click event of that button to close the form.
5. Run the Application with shortcut F5.
6. in the above example if you want to calculate sum when user press enter key and close the form when user press escape key, set sum button as acceptbutton for the form and close button as cancelbutton for the form.
RELATED C#.NET SNIPPETS
Label in C# Winforms
Example for winforms keypress event
Example for Winforms keydown event with modifier keys
Working with forms keyup and keydown events
Working With Winform Textbox Enter And Leave Events
Windows Forms Events or Winform Events
Windows Application Form
Developing Windows Application in .NET
c# windows applications, window forms c#, windows form example c# , windows form c#.net, c# windows form, , windows applications c#, examples of windows application in .net, windows form application example, windows application examples, examples of windows application, example of windows application, examples of windows applications