In Chapter 2, we demonstrated tool tipsthe helpful text that appears when the mouse hovers over an item in a GUI. Recall that the tool tips displayed in Visual Studio help you become familiar with the IDE's features and serve as useful reminders for each toolbar icon's functionality. Many programs use tool tips to remind users of each control's purpose. For example, Microsoft Word has tool tips that help users determine the purpose of the application's icons. This section demonstrates how use the ToolTip component to add tool tips to your applications. Figure 13.31 describes common properties and a common event of class ToolTip.

Figure 13.31. ToolTip properties and events.

ToolTip properties and events


Common Properties


The amount of time (in milliseconds) that the tool tip appears while the mouse is over a control.


The amount of time (in milliseconds) that a mouse must hover over a control before a tool tip appears.


The amount of time (in milliseconds) between which two different tool tips appear (when the mouse is moved from one control to another).

Common Event


Raised when the tool tip is displayed. This event allows programmers to modify the appearance of the tool tip.

When you add a ToolTip component from the Toolbox, it appears in the component traythe gray region below the Form in Design mode. Once a ToolTip is added to a Form, a new property appears in the Properties window for the Form's other controls. This property appears in the Properties window as ToolTip on, followed by the name of the ToolTip component. For instance, if our Form's ToolTip were named helpfulToolTip, you would set a control's ToolTip on helpfulToolTip property value to specify the control's tool tip text. Figure 13.32 demonstrates the ToolTip component. For this example, we create a GUI containing two Labels, so we can demonstrate different tool tip text for each Label. To make the sample outputs clearer, we set the BorderStyle property of each Label to FixedSingle, which displays a solid border. Since there is no event-handling code in this example, the class in Fig. 13.32 contains only a constructor.

Figure 13.32. Demonstrating the ToolTip component.

 1 // Fig. 13.32: ToolTipExampleForm.cs
 2 // Demonstrating the ToolTip component.
 3 using System;
 4 using System.Windows.Forms;
 6 public partial class ToolTipExampleForm : Form
 7 {
 8 // default constructor
 9 public ToolTipExampleForm()
10 {
11 InitializeComponent();
12 } // end constructor
14 // no event handlers needed for this example
16 } // end class ToolTipExampleForm



In this example, we named the ToolTip component labelsToolTip. Figure 13.33 shows the ToolTip in the component tray. We set the tool tip text for the first Label to "First Label" and the tool tip text for the second Label to "Second Label". Figure 13.34 demonstrates setting the tool tip text for the first Label.

Figure 13.33. Demonstrating the component tray.

Figure 13.34. Setting a control's tool tip text.



    Introduction to Computers, the Internet and Visual C#

    Introduction to the Visual C# 2005 Express Edition IDE

    Introduction to C# Applications

    Introduction to Classes and Objects

    Control Statements: Part 1

    Control Statements: Part 2

    Methods: A Deeper Look


    Classes and Objects: A Deeper Look

    Object-Oriented Programming: Inheritance

    Polymorphism, Interfaces & Operator Overloading

    Exception Handling

    Graphical User Interface Concepts: Part 1

    Graphical User Interface Concepts: Part 2


    Strings, Characters and Regular Expressions

    Graphics and Multimedia

    Files and Streams

    Extensible Markup Language (XML)

    Database, SQL and ADO.NET

    ASP.NET 2.0, Web Forms and Web Controls

    Web Services

    Networking: Streams-Based Sockets and Datagrams

    Searching and Sorting

    Data Structures



    Appendix A. Operator Precedence Chart

    Appendix B. Number Systems

    Appendix C. Using the Visual Studio 2005 Debugger

    Appendix D. ASCII Character Set

    Appendix E. Unicode®

    Appendix F. Introduction to XHTML: Part 1

    Appendix G. Introduction to XHTML: Part 2

    Appendix H. HTML/XHTML Special Characters

    Appendix I. HTML/XHTML Colors

    Appendix J. ATM Case Study Code

    Appendix K. UML 2: Additional Diagram Types

    Appendix L. Simple Types


    Visual C# How to Program
    Visual C# 2005 How to Program (2nd Edition)
    ISBN: 0131525239
    EAN: 2147483647
    Year: 2004
    Pages: 600 © 2008-2020.
    If you may any questions please contact us: