New to Telerik UI for WinFormsStart a free 30-day trial

Screen Tips

Updated over 6 months ago

Screen Tip is a UI feature which consists of a small window that appears when the mouse cursor is hovered over a particular element. By default each control has a ScreenTipNeeded event which is fired when the mouse hovers over the various elements inside the control. The screen tip extends the tooltips functionality because it can show many different elements including images.

Figure 1: A ScreenTip in RadGridView.

tpf-screen-tip001

The RadOffice2007ScreenTipElement is the screen tip that is currently available in the Telerik UI for WinForms suite.This screen tip contains 3 labels and a line which is used to separate the footer. Each label element can display an image as well. The following image shows the elements that are used inside this screen tip.

Figure 2: RadOffice2007ScreenTipElement.

tpf-screen-tip002

The following example demonstrates how you can show a tooltip when a RadListView item is hovered. Please note that the Item property contains the currently hovered element.

C#
RadOffice2007ScreenTipElement screenTip = new RadOffice2007ScreenTipElement();
private void RadListView1_ScreenTipNeeded(object sender, Telerik.WinControls.ScreenTipNeededEventArgs e)
{
    var dataItem = e.Item as SimpleListViewVisualItem;
    if (e.Item != null)
    {
        screenTip.CaptionLabel.Text = "Select Employee Name";
        screenTip.MainTextLabel.Text = "Current: " + dataItem.Text;
        screenTip.FooterTextLabel.Text = "Thank you!";
        screenTip.FooterVisible = true;
        dataItem.ScreenTip = screenTip;
    }
}

Figure 3: Screen tip in RadListView

tpf-screen-tip003

To determine which are the exact elements types, just add the following statement to the ScreenTipNeeded event: Console.WriteLine(e.Item), this way when you are hovering the elements, their types will be displayed in the console.

Custom Tooltips

To create custom tooltips you need to create a class that inherits RadScreenTipElement. You can add any elements to this class. The following code shows how you can add a simple element which only shows image and text:

Create custom screen tip

C#
class MyScreenTip : RadScreenTipElement
{
    LightVisualElement contentElement = new LightVisualElement();
    public LightVisualElement ContentElement
    {
        get
        {
            return contentElement;
        }
    }
    protected override void CreateChildElements()
    {
        base.CreateChildElements();
        contentElement.DrawFill = true;
        contentElement.DrawText = true;
        contentElement.GradientStyle = GradientStyles.Solid;
        contentElement.TextImageRelation = TextImageRelation.ImageBeforeText;
        this.Children.Add(contentElement);
    }
}

You can use this element as the default screen tips.

Use the custom screen tip

C#
MyScreenTip myScreenTip = new MyScreenTip();
private void RadGridView1_ScreenTipNeeded(object sender, ScreenTipNeededEventArgs e)
{
    if (e.Item is GridDataCellElement)
    {
        var cell = e.Item as GridDataCellElement;
        myScreenTip.ContentElement.Text = cell.Text;
        myScreenTip.ContentElement.Image = img;
        myScreenTip.ContentElement.BackColor = Color.LightBlue;
        e.Item.ScreenTip = myScreenTip;
    }
}

See Also

In this article
Custom TooltipsSee Also
Not finding the help you need?
Contact Support