Zebra0.com

csharp controls

Names

C# gives controls a default name: the first label is named label1; the second label will be label2, and so on.
It is important to change the names of the controls; lblGreeting and picComputer are easier to work with than trying to remember whether pictureBox1 is the computer or the printer.
It is a good habit to name the control as soon as you add it to the form.
You are probably thinking something like, "I need a label to display a greeting," so immediately naming the label lblGreeting makes sense.
In order to make our projects easier to work with, we will start giving our controls names.

The (Name) property is inside parenthesis and is almost at the top of the property list.

When you type a name for a control you can not use any spaces or any special characters except the underscore.
Most programmers use what is sometimes called "Camel Case" - each "word" in the name begins with a capital letter.
It is easier to understand textBoxLastName, than textBox1.

End of lesson, Next lesson: