In this chapter you have learned how to create your own custom control by extending an existing control. This illustrates the power that inheritance brings to the object-oriented programming table. Just think of all the code you would have to write for your custom control if you were not able to inherit the base functionality of the TextBox control!

The PhoneSSN control is useful, but it could benefit from some additional work. For example, it should ensure that the data entered in each of the text boxes is numeric only. Also, you might add some formatting options for the phone number. Some people prefer phone numbers in the (123)456-7890 format, and others prefer 123-456-7890 or 123.456.7890. You could use the Enum technique presented in this chapter to add a new format property to accommodate these different styles.

Although modifying the code presented in this chapter is a good learning experience, you will learn a lot more if you try to build your own custom control from scratch. I won't even begin to tell you about all the flat-forehead mistakes I made while creating my first custom control. Still, it is an invaluable way to learn how all the pieces discussed in this chapter fit together, so give it a try!

Visual Basic .NET. Primer Plus
Visual Basic .NET Primer Plus
ISBN: 0672324857
EAN: 2147483647
Year: 2003
Pages: 238
Authors: Jack Purdum

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: