True DBGrid for WinForms | ComponentOne
In This Topic
    Scrollbar
    In This Topic

    Scrolling in True DBGrid comes into picture when a huge amount of grid data needs to be plotted in a limited space but requires thorough analysis. This feature provides the end-user with an ability to focus on the analysis of the selected range of values instead of the entire data.

    Scroll Tracking and ScrollTips

    True DBGrid uses the ScrollTrack property to get or set a value that controls how the grid scrolls when the scroll thumb is moved. If the ScrollTrack property is set to True, moving the scrollbar thumb can cause vertical scrolling of the grid display. By default, this property is False, and no scrolling occurs until the thumb is released. Also, if the ScrollTips property is set to True, moving the scrollbar thumb causes the FetchScrollTips event to fire. Use this event to track the position of the scroll bar on a record-by-record basis. Also use this event to present the user with useful information relating to the current record or recordset. When used in tandem, the ScrollTrack and ScrollTips properties provide users with visual feedback when scrolling through large DataSets.

    Cell Tips

    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.

    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:

    C#
    Copy Code
    private void Form1_Load(object sender, EventArgs e)
    {
        // we'll use the grid's celltip eventing to control supertooltip visibility
        this.c1TrueDBGrid1.CellTips = C1.Win.C1TrueDBGrid.CellTipEnum.Anchored;
    
        // no delay for showing, very long time to hide
        c1SuperTooltip1.AutomaticDelay = 0;
        c1SuperTooltip1.AutoPopDelay = int.MaxValue;
        // make an empty grid
        FillGrid(this.c1TrueDBGrid1);
    }
    private void c1TrueDBGrid1_FetchCellTips(object sender, C1.Win.C1TrueDBGrid.FetchCellTipsEventArgs e)
    {
        // setting e.CellTip to an empty string disables the built-in celltip
        e.CellTip = string.Empty;
    
        // now use supertooltip
        C1.Win.C1TrueDBGrid.C1TrueDBGrid tdbgrid = sender as C1.Win.C1TrueDBGrid.C1TrueDBGrid;
    
        // save the current row and column index, we'll use this in MouseMove
        this._rowcol = new Point(e.ColIndex, e.Row);
        string tip = _tip.Replace("(row,col)", string.Format("<b>({0},{1})</b>",e.Row, e.ColIndex));
        this.c1SuperTooltip1.SetToolTip(tdbgrid, tip);
    }