Back to Devexpress

ContextItem.CustomToolTip Event

windowsforms-devexpress-dot-utils-dot-contextitem-c94e9b55.md

latest6.1 KB
Original Source

ContextItem.CustomToolTip Event

Allows you to specify a tooltip shown when the mouse pointer hovers over a context button. This event is only raised for RatingContextButton and TrackBarContextButton objects.

Namespace : DevExpress.Utils

Assembly : DevExpress.Utils.v25.2.dll

NuGet Packages : DevExpress.Utils, DevExpress.Wpf.Core

Declaration

csharp
public event ContextButtonToolTipEventHandler CustomToolTip
vb
Public Event CustomToolTip As ContextButtonToolTipEventHandler

Event Data

The CustomToolTip event's data class is DevExpress.Utils.ContextButtonToolTipEventArgs.

Remarks

Use a context button’s SuperTip property to assign a super tooltip to the button. To assign a regular tooltip, use the following properties:

  • ToolTip — gets or sets the tooltip text.
  • ToolTipTitle — gets or sets the title displayed above the text.
  • ToolTipIconType — gets or sets the icon that indicates whether the tooltip contains an error, warning, question, or other information.

See the following topic for more information about regular and super tooltips: Hints and Tooltips.

Rating Scale and Track Bar

The RatingContextButton and TrackBarContextButton show the current rating and track value in the default tooltips.

You can handle the owner control’s CustomContextButtonToolTip or the button’s CustomToolTip event to specify custom tooltips. Use the Value event argument to obtain the current value and the Text event argument to specify the tooltip text.

Note

The owner control’s CustomContextButtonToolTip event fires after the button’s CustomToolTip event and overrides its tooltips. Also note that these events do not fire if a super or regular tooltip is assigned to the button.

Disable Tooltips

You can also disable the owner control’s ShowToolTips option to hide tooltips. The button’s ShowToolTips property overrides this option for an individual button.

csharp
pictureEdit1.Properties.ContextButtonOptions.ShowToolTips = false;
vb
pictureEdit1.Properties.ContextButtonOptions.ShowToolTips = False

Note

If a context button’s Enabled property is set to false , tooltips are not displayed regardless of the owner control’s ShowToolTips option or the button’s ShowToolTips property.

Example

The code below handles the ContextItem.CustomToolTip event to assign different tooltips to each of the five rating grades.

csharp
using DevExpress.XtraGrid.Views.WinExplorer;

winExplorerView1.ContextButtons["itemRating"].CustomToolTip += (s, e) => {
    decimal rating = (decimal)e.Value;
    if (0 < rating && rating <= 1)
        e.Text = "Very Bad";
    else if (1 < rating && rating <= 2)
        e.Text = "Bad";
    else if (2 < rating && rating <= 3)
        e.Text = "Average";
    else if (3 < rating && rating <= 4)
        e.Text = "Good";
    else if (4 < rating && rating <= 5)
        e.Text = "Excellent";
    else
        e.Text = String.Empty;
};
vb
Imports DevExpress.XtraGrid.Views.WinExplorer

AddHandler winExplorerView1.ContextButtons("itemRating").CustomToolTip, AddressOf CustomToolTipEventHandler

Sub CustomToolTipEventHandler(sender As Object, e As ContextButtonToolTipEventArgs)
    Dim rating As Decimal = Convert.ToDecimal(e.Value)
    If 0 < rating AndAlso rating <= 1 Then
        e.Text = "Very Bad"
    ElseIf 1 < rating AndAlso rating <= 2 Then
        e.Text = "Bad"
    ElseIf 2 < rating AndAlso rating <= 3 Then
        e.Text = "Average"
    ElseIf 3 < rating AndAlso rating <= 4 Then
        e.Text = "Good"
    ElseIf 4 < rating AndAlso rating <= 5 Then
        e.Text = "Excellent"
    Else
        e.Text = String.Empty
    End If
End Sub

See Also

RepositoryItemPictureEdit.CustomContextButtonToolTip

PictureEdit.CustomContextButtonToolTip

StandaloneGallery.CustomContextButtonToolTip

WinExplorerView.CustomContextButtonToolTip

ToolTip

SuperTip

Context Buttons

ContextItem Class

ContextItem Members

DevExpress.Utils Namespace