Learn C# (C sharp) in FREE step-by-step lessons.
Unit I: Introduction

We have learned to change properties at design time.
In this lesson we will learn to write code.
In C# we will write code to execute when an event occurs:
- when the form loads,
- when the user clicks a button,
- or makes a choice,
- or one of the other events that occur.
Sometimes we will use the code to change properties of the form or the controls.
For instance we want to change the backcolor of the form when the user clicks BtnRed.
We may want to hide a control under certain circumstances.
The possibilities are endless! Let's get started!
Please study the material at each of the links below.
Microsoft Reference: C# Coding Standards
Writing Code to change properties of the form: Instead of changing properties in the design view, it can be done with code.- Comments: Comments are notes a programmer makes about the code
Code created: An explanation of each line of code
Adding events for controls: Some events can be added by double clicking on the control
Adding items to listbox at runtime: Clicking a button adds the conents of a text box to a list box.
Changing the location of a control: The location is a Point with x and y values
Mouse Move Event, Arguments: The mousemove event has argument e that has the location
Using the TextBox Control: After user types their name and presses a button,
a greeting is displayed
Using the Scroll Bar Control: A scrollbar is used to select inches
Debugging Tools: A few tools for debugging are shown
Creating a Console App: A console app runs in the system window instead of a form
Glossary for code lesson
Full Glossary