Chapter 10. Building Custom Dialogs

The standard dialogs described in Lesson 8 make it easy to perform typical chores such as picking files, folders, colors, and fonts. Those dialogs can get you pretty far, but sometimes you may want a dialog that is customized for your application.

For example, you might want to display a dialog in which the user can enter a new customer's contact information (name, address, phone number, hat size, and so on). It's unlikely that any predefined standard dialog exists for that exact situation.

Fortunately, it's easy to build custom dialogs. All you need to do is build a new form as described in Lesson 9, add a few buttons, and set a few properties.

In this lesson you learn how to build custom dialogs and make them as easy to use as the standard dialogs that come with Visual Basic.

MAKING CUSTOM DIALOGS

Building a custom dialog is pretty easy. Simply add a new form to your project as described in Lesson 9 and give it whatever controls you need.

To allow the user to finish using the dialog, add one or more buttons. Some dialogs have a single OK button. Others have OK and Cancel buttons, or some other combination of buttons. Because you're creating the dialog, you can give it whatever buttons you like.

FIGURE 10-1

Figure 10.1. FIGURE 10-1

By convention, the buttons go at the bottom of the dialog in the right corner. Figure 10-1 shows a very simple dialog that contains a ...

Get Stephens' Visual Basic® Programming 24-Hour Trainer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.