ComponentOne True DBGrid for WinForms
Context-Sensitive Help with CellTips
Data Presentation Techniques > Context-Sensitive Help with CellTips

In many Windows applications, when the user points to a toolbar button and leaves the mouse at rest for a short time, a ToolTip window appears with the name of the associated command. Provide similar context-sensitive help for users with the CellTips property of True DBGrid for WinForms.

The CellTips property determines whether the grid displays a pop-up text window when the cursor is idle. By default, this property is set to CellTipEnum.NoCellTips, and cell tips are not displayed.

If the CellTips property is set to eitherCellTipEnum.Anchored or CellTipEnum.Floating, the FetchCellTips event will be fired whenever the grid has focus and the cursor is idle over a grid cell, record selector, column header, column footer, split header, or grid caption. The event will not fire if the cursor is over the scroll bars.

The setting CellTipEnum.Anchored aligns the cell tip window with either the left or right edge of the cell. The left edge is favored, but the right edge will be used if necessary in order to display as much text as possible.

The setting CellTipEnum.Floating displays the cell tip window below the cursor, if possible.

If a handler is not provided for the FetchCellTips event, and the cursor is over a grid cell, the default behavior is to display a text box containing the cell's contents (up to 256 characters). This enables the user to peruse the contents of a cell even if it is not big enough to be displayed in its entirety. The FetchCellTips event can be programmed to override the default cell text display in order to provide users with context-sensitive help.

A common application of the FetchCellTips event is to display the contents of an invisible column that provides additional information about the row being pointed to, as in the following example:

To write code in Visual Basic

Visual Basic
Copy Code
' General Declarations.
Dim DescCol As C1.Win.C1TrueDBGrid.C1DataColumn
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ' Set the column to be displayed as a CellTip.
    DescCol = Me.C1TrueDBGrid1.Columns("Country")
    Me.C1TrueDBGrid1.CellTips = C1.Win.C1TrueDBGrid.CellTipEnum.Floating
End Sub
Private Sub C1TrueDBGrid1_FetchCellTips(ByVal sender As System.Object, ByVal e As C1.Win.C1TrueDBGrid.FetchCellTipsEventArgs) Handles C1TrueDBGrid1.FetchCellTips
    ' Display the column.
    e.CellTip = DescCol.CellText(e.Row)
End Sub

To write code in C#

Copy Code
// General Declarations.
C1.Win.C1TrueDBGrid.C1DataColumn DescCol;
private void Form1_Load(System.object sender, System.EventArgs e)
    // Set the column to be displayed as a CellTip.
    DescCol = this.c1TrueDBGrid1.Columns["Country"];
    this.c1TrueDBGrid1.CellTips = C1.Win.C1TrueDBGrid.CellTipEnum.Floating;
private void C1TrueDBGrid1_FetchCellTips(System.object sender, C1.Win.C1TrueDBGrid.FetchCellTipsEventArgs e)
    // Display the column.
    e.CellTip = DescCol.CellText(e.Row);

Use the CellTipsDelay property to control the amount of time that must elapse before the cell tip window is displayed.

Use the CellTipsWidth property to control the width of the cell tip window.

See Also