The Workshop is designed to help you anticipate possible questions, review what you've learned, and get you thinking about how to put your knowledge into practice.
Quiz
1.
Name three things that can cause events to occur.
2.
True or False: All objects support the same set of events.
3.
What is the default event type for a button?
4.
Writing code in an event that causes that same event to be triggered, setting off a chain reaction with the event triggered again and again is called what?
5.
What is the easiest way to access a control's default event handler?
6.
All control events pass a reference to the control causing the event. What is the name of the parameter that holds this reference?
Answers
1.
User input, system input, and other code
2.
False
3.
Click
4.
Recursion
5.
Double-click the control in the form designer
6.
Sender
Exercises
1.
Use the knowledge you've gained so far to create a new project with a form that is gray at design time but that appears blue when the form displays.
2.
Create a project with a form and a text box. Add code to the TextChange event to cause a recursion when the user types in text. Hint: Concatenate a character to the end of the user's text using a statement such as
txtMyTextBox.Text = txtMyTextBox.Text + "a";
The + sign tells Visual C# to add the letter a to the end of the existing text box contents. Notice how you eventually get a Stack Over-Flow errornot a good thing!