Form Adornments


In addition to size and location, forms have a number of properties that manage various other aspects of their appearance and corresponding behavior. The following settings govern the nonclient adornments of a form: those parts of a form outside the client area that are drawn by Windows:

  • FormBorderStyle sets whether the form has a border, whether it can be resized, and whether it has a normal-sized or small caption. Good forms and dialogs have the default value of Sizable. Annoying dialogs change this property to one of the nonsizable options. Generally, programmers choose nonsizable options because of control-layout issues, but Windows Forms handles that nicely, as discussed in Chapter 4.

    In addition, there are two tool window stylesone fixed and one sizablefor use in building floating tool strip-style windows. You'll find an implementation of this in the sample for Chapter 4.

  • ControlBox is a Boolean determining whether Windows shows the icon on the upper left corner of the form as well as the close button on the upper right. If ControlBox is set to false, neither left-clicking on the upper-left corner of the form nor right-clicking on the caption shows the System menu. Similarly, when ControlBox is false, the MaximizeBox and MinimizeBox properties are ignored, and those buttons are not shown. This property defaults to true but is often set to false for modal dialogs.

  • The MaximizeBox and MinimizeBox properties determine whether the maximize and minimize buttons are shown on the form's caption. These properties default to true but are often set to false for modal dialogs.

  • The HelpButton property shows the question mark button next to the close button in the upper right corner, but only if ControlBox is set to true and MaximizeBox and MinimizeBox are both set to false. This property defaults to false but is often set to true for modal dialogs. When the user clicks on the help button and then somewhere else on the form, the HelpRequested event is fired and the form provides the user with help. Whether the HelpButton property is true or false, the HelpRequested event is always fired when the user presses F1.

  • The Icon property determines the image used as the icon for the form.

  • The ShowIcon property hides or shows the form's icon.

  • The SizeGripStyle property allows values from the SizeGripStyle enumeration: Auto, Hide, or Show. A size grip is the adornment on the lower-right corner of a window that indicates that it can be resized. The default is Auto and indicates showing the size grip in the lower-right corner "if needed," depending on the form's FormBorderStyle property. The Auto setting judges the size grip needed if the form is sizable and is shown modally. Also, if the form has a status strip control, the form's SizeGripStyle is ignored in favor of the SizingGrip Boolean property on the StatusStrip control (covered later in this chapter), if used.

  • ShowInTaskbar is a Boolean governing whether the form's Text property appears in a button on the shell's task bar. This property defaults to true but is often set to false for modal forms.

Although most of the properties are independent of each other, not all of these combinations work together. For example, when FormBorderStyle is set to either of the tool window settings, no maximize or minimize box is shown, regardless of the value of the MaximizeBox and MinimizeBox properties. Experimentation will reveal what works and what doesn't.




Windows Forms 2.0 Programming
Windows Forms 2.0 Programming (Microsoft .NET Development Series)
ISBN: 0321267966
EAN: 2147483647
Year: 2006
Pages: 216

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net