Creating a Status Bar

   

The last control I'm going to show you is the Status Bar control. The status bar isn't nearly as fancy, or even as useful, as other controls, such as the Toolbar or the Main Menu. It's also not that hard to work with. Nevertheless, a status bar adds value to an application in that it makes additional information available, and users have come to expect it. In its simplest form, a status bar displays a text caption and sizing grip ”the three diagonal lines to the right of the control that the user can drag with the mouse to change the size of the form.

Add a new status bar to the form now by double-clicking the StatusBar item in the toolbox. Change the name of the status bar to sbrMyStatusBar. The Text property determines the text displayed in the left side of the status bar. Notice that the Text is set to the default name of the control. Change the Text property to Menus and Toolbars Example now, and notice how the text in the status bar changes (see Figure 9.13).

Figure 9.13. Status bars dress out a form.

graphics/09fig13.jpg


If a form's border is sizable , the user can click and drag the sizing grip at the right side of the status bar to change the size of the form. The status bar isn't smart enough to realize when a form's border can't be resized; you'll have to change the SizingGrip property of the status bar to false to hide the grip.

The default behavior of the status bar is quite simple, consisting of text and a sizing grip. However, you can create more complex status bars with this control. The Status Bar control contains a Panels collection. To see how a panel works, select the Panels property in the Properties window and click the small button that appears. On the StatusBarPanel Collection Editor, click Add to create a new panel. Set the Text of the panel to Panel Text, set the AutoSize property to Contents, and click OK to save your changes. Nothing looks different, right? This is because one last thing is required to display the status bar panels. Change the ShowPanels property of the status bar to true now, and the status bar will display its panel (see Figure 9.14). You can add multiple panels to a Status Bar control and even tailor the appearance of each panel by changing the border style or displaying an image from a linked Image List control. The status bar is such a simple control that you may overlook using it. However, I encourage you to use it when appropriate.

Figure 9.14. Status bars can display custom panels.

graphics/09fig14.jpg



   
Top


Sams Teach Yourself C# in 24 Hours
Sams Teach Yourself Visual Basic 2010 in 24 Hours Complete Starter Kit (Sams Teach Yourself -- Hours)
ISBN: 0672331136
EAN: 2147483647
Year: 2002
Pages: 253
Authors: James Foxall

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