Designing the Dialog

Now that our game plan has be mapped out, we can design and construct the dialog. The final product is shown in Figure 19-30. It is a UserForm called dlgSelectSpecial, and its Caption property should be set to "Select Special."

Figure 19-30. Select Special dialog

different From Previous Cell ::: C same AiPrevtiuscell ::: C £mpty ::: I Not Erretv

complete Roans

Campled Co - ;mns

S£3FCh R-ange



As to the operation of the utility, the user will first select one of the mutually exclusive options under Select Cells If. The actual search range is displayed at the bottom of the dialog.

Here are some of the highlights of this form design. We suggest you read on before creating your own form. The Frame control

A frame control is used to group other controls. This is often done just to group controls that have a similar purpose. However, in the case of option buttons, it has a more profound effect. Namely, the option buttons in a single frame are mutually exclusive, which means that if the user selects one option button, the others are automatically unselected.

To ensure that the option buttons are really inside the frame and not merely on top of it, make sure the frame is selected when you click on the OptionButton control icon in the Toolbox. Then create the option button inside the frame. Also, if you decide to copy and paste the additional option buttons, make sure that the frame is selected when you choose the Paste command. Control names

The control names were chosen to conform to my naming convention. Their names are:

• optDifferent

• cmdCompleteRows

• cmdCompleteColumns

• lblSearchRange

You will not need to set many control properties beyond the Name property and the Accelerator property (indicated for each control in Figure 19-30 by an underscore in its caption). Be sure to set the WordWrap property of the lblSearchRange label to False so that the label will occupy only a single line. Also, set the TabStop property of lblSearchRange to False. Tab Order

It is important whenever designing a custom dialog to set the tab order of all controls properly. There is nothing less professional than having the focus jump around randomly when the user repeatedly hits the Tab key! The simplest way to set the correct tab order is to use the Tab Order dialog box, available from the View menu and shown in Figure 19-31. You can use this dialog to get an overall view of the current tab order and to change that order, if desired. Remember that the control with tab order 0 will receive the focus when the dialog is first displayed. You will need to display the Tab Order dialog twice: once while the entire dialog is selected and once while the frame control is selected (to see the tab orders of the option buttons).

Figure 19-31. The Tab Order dialog

Figure 19-31. The Tab Order dialog Some final tips

We should remark that the VB editor's Format menu has some very useful items for aligning and resizing controls on a UserForm to give your forms a more professional look. You should definitely do some exploration of this menu. Another useful trick is to copy and paste controls. This produces controls of identical size and preserves other properties as well. (Of course, some properties, such as the Name property or the position properties, are not preserved.)

0 0

Post a comment