New to Telerik UI for WinForms? Download free 30-day trial

How to show tooltip on disabled element in RibbonBar

Environment

Product Version 2018.2.621
Product RadRibbonBar for WinForms

Problem

When a particular element is disabled the Tooltip and SreeenTip events will not fire and there is no way to show the user why element is disabled.

Solution

Use the MouseMove event and show a custom tooltip when a disabled element is hovered:

RadToolTip toolTip = new RadToolTip();
RadButtonElement prevElement = null;

private void RadRibbonBar1_MouseMove(object sender, MouseEventArgs e)
{
    var element = radRibbonBar1.ElementTree.GetElementAtPoint(e.Location) as RadButtonElement;
    if (e.Button == MouseButtons.None && element != null && !element.Enabled)
    {
        if (prevElement != element)
        {
            toolTip.Show("Disabled because...", Cursor.Position, 2000);
        }
        prevElement = element;
    }           
}
Private toolTip As New RadToolTip()
Private prevElement As RadButtonElement = Nothing
Private Sub RadRibbonBar1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs)
    Dim element = TryCast(radRibbonBar1.ElementTree.GetElementAtPoint(e.Location), RadButtonElement)
    If e.Button = MouseButtons.None AndAlso element IsNot Nothing AndAlso Not element.Enabled Then
        If prevElement IsNot element Then
            toolTip.Show("Disabled because...", Cursor.Position, 2000)
        End If
        prevElement = element
    End If
End Sub
In this article