From webpage
Adding Features to a Windows Forms Application - The property settings for the Invoice Total form
(Page 3 of 5 )
Figure 2-8 shows the property settings for the Invoice Total form. As you can see, you don't need to change many properties to finish the design of this form. You only need to set four properties for the form, and you only use six of the properties (Name, Text, TextAlign, ReadOnly, TabStop, and TabIndex) for the controls. Depending on the order in which you create the controls, though, you may not need to change the TabIndex settings.
Notice that the three text boxes that display the form's calculation have their ReadOnly property set to True. This setting gives the text boxes a shaded appearance, as you saw in figure 2-3, and it prevents the user from entering text into these controls. In addition, the TabStop property for these text boxes has been set to False so the user can't use the Tab key to move the focus onto these controls.
Finally, the settings for the TabIndex properties of the text box and the two buttons are 1, 2, and 3. Since the label controls can't receive the focus, and since the TabStop property for the three read-only text boxes has been set to False, the user can press the Tab key to move the focus from the Subtotal text box to the Calculate button to the Exit button.
In addition, the Subtotal label has a TabIndex property of 0 and a Text property that includes an access key of S. As a result, the user can press Alt+S to move the focus to the control that has the next available tab index. In this case, that control is the Subtotal text box, which has a TabIndex property of 1.
Of course, this is just one way that the TabIndex properties could be set. If, for example, the TabIndex properties for the 10 controls were set from 0 through 9, from top to bottom in this summary, the tab order would work the same.
How to use Document Outline view
Document Outline view is a feature that became available with Visual Studio2005. To open the window for this view, you use the View->Other Windows->Document Outline command. This opens a window to the left of the Form Designer that lists the names of all of the controls that have been added to the current form.
This view makes it easy to check whether you've named all of the controls that you're going to refer to in your Visual Basic code. You can also select a control in the Form Designer by clicking on the name of the control in Document Outline view. Although these are minor benefits, it's worth experimenting with this view to see whether you're going to want to use it.
The property settings for the form
Form1 | Text | Invoice Total |
| AcceptButton | btnCalculate |
| CancelButton | btnExit |
| StartPosition | CenterScreen |
The property settings for the controls
Default name | Property | Setting |
---|---|---|
Label1 | Text | &Subtotal: |
TextAlign TabIndex | MiddleLeft 0 | |
Label2 | Text TextAlign | Discount percent: MiddleLeft |
Label3 | Text | Discount amount: |
TextAlign | MiddleLeft | |
Label4 | Text | Total: |
TextAlign | MiddleLeft | |
TextBox1 | Name | txtSubtotal |
TabIndex | 1 | |
TextBox2 | Name | txtDiscountPercent |
ReadOnly TabStop | True False | |
TextBox3 | Name | txtDiscountAmount |
ReadOnly TabStop | True False | |
TextBox4 | Name | txtTotal |
ReadOnly TabStop | True False | |
Button1 | Name | btnCalculate |
Text | &Calculate | |
TabIndex | 2 | |
Button2 | Name | btnExit |
Text | E&xit | |
TabIndex | 3 |
Note
- To provide an access key for the Subtotal text box, you can set the TabIndex and Text properties for the Subtotal label as shown above.
Figure 2-8. The property settings for the Invoice Total form
No comments:
Post a Comment