Version

ToolTipDisplaying Event

Occurs before a tooltip is displayed for an UltraListViewItem.
Syntax
'Declaration
 
Public Event ToolTipDisplaying As ToolTipDisplayingEventHandler
public event ToolTipDisplayingEventHandler ToolTipDisplaying
Event Data

The event handler receives an argument of type ToolTipDisplayingEventArgs containing data related to this event. The following ToolTipDisplayingEventArgs properties provide information specific to this event.

PropertyDescription
Cancel (Inherited from System.ComponentModel.CancelEventArgs) 
IsToolTipForSubItem Returns whether the ToolTip is being displayed for an UltraListViewSubItem.
Item (Inherited from Infragistics.Win.UltraWinListView.CancelableItemEventArgs)Returns the UltraListViewItem with which this instance is associated.
Location Gets/sets the location at which the ToolTip is displayed, expressed in screen coordinates.
SubItem Returns the UltraListViewSubItem for which the ToolTip is being displayed, or null if the ToolTip is not being displayed for an UltraListViewSubItem.
ToolTipText Gets/sets the text that will be displayed in the ToolTip.
Example
The following code sample demonstrates how to handle the ToolTipDisplaying event to customize the tooltip that appears when the cursor hovers over an UltraListViewItem:

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Win
Imports Infragistics.Win.UltraWinListView

	 '	Show tooltips for items whether the value is fully visible or not
    Me.ultraListView1.ItemSettings.TipStyle = ItemTipStyle.ShowAlways
    Me.ultraListView1.ViewSettingsDetails.SubItemTipStyle = SubItemTipStyle.ShowIfNeeded

    Private Sub ultraListView1_ToolTipDisplaying(ByVal sender As Object, ByVal e As ToolTipDisplayingEventArgs) Handles lvwFiles.ToolTipDisplaying

        '	Override the default tooltip behavior for folder items,
        '	so we can display a summary of the contents of the folder
        '	when the end user hovers over the item.
        If (e.IsToolTipForSubItem) Then Return

        Dim item As UltraListViewItem = e.Item

        Dim directoryInfo As directoryInfo = Nothing
        If item.Tag.GetType() Is GetType(directoryInfo) Then directoryInfo = CType(item.Tag, directoryInfo)

        If (Not directoryInfo Is Nothing) Then

            Dim sb As StringBuilder = New StringBuilder()
            Dim directories As directoryInfo() = directoryInfo.GetDirectories()
            Dim files As FileInfo() = directoryInfo.GetFiles()

            Dim limiter As Integer = 0
            Dim i As Integer

            If (directories.Length = 0 AndAlso files.Length = 0) Then
                sb.Append("Folder is empty")
            ElseIf (directories.Length > 0) Then

                sb.Append(directoryInfo.Name)
                sb.Append(Environment.NewLine)
                sb.Append("Folders: ")
                sb.Append(Environment.NewLine)

                limiter = Math.Min(5, directories.Length - 1)
                For i = 0 To limiter
                    sb.Append(directories(i).Name)
                    If (i < limiter) Then sb.Append(", ")
                Next

                If (limiter < (directories.Length - 1)) Then sb.Append("...")

            ElseIf (files.Length > 0) Then

                sb.Append(directoryInfo.Name)
                sb.Append(Environment.NewLine)
                sb.Append("Files: ")
                sb.Append(Environment.NewLine)

                limiter = Math.Min(5, files.Length - 1)
                For i = 0 To limiter
                    sb.Append(files(i).Name)
                    If (i < limiter) Then sb.Append(", ")
                Next

                If (limiter < (files.Length - 1)) Then
                    sb.Append("...")
                End If
            End If

            e.ToolTipText = sb.ToString()
        End If
    End Sub
using Infragistics.Win;
using Infragistics.Win.UltraWinListView;
using System.Diagnostics;

		//	Show tooltips for items whether the value is fully visible or not
		this.ultraListView1.ItemSettings.TipStyle = ItemTipStyle.ShowAlways;
		this.ultraListView1.ViewSettingsDetails.SubItemTipStyle = SubItemTipStyle.ShowIfNeeded;

		private void ultraListView1_ToolTipDisplaying(object sender, Infragistics.Win.UltraWinListView.ToolTipDisplayingEventArgs e)
		{
			//	Override the default tooltip behavior for folder items,
			//	so we can display a summary of the contents of the folder
			//	when the end user hovers over the item.
			if ( e.IsToolTipForSubItem )
				return;

			UltraListViewItem item = e.Item;
			DirectoryInfo directoryInfo = item.Tag as DirectoryInfo;
			if ( directoryInfo != null )
			{
				StringBuilder sb = new StringBuilder();
				DirectoryInfo[] directories = directoryInfo.GetDirectories();
				FileInfo[] files = directoryInfo.GetFiles();
				int limiter = 0;

				if ( directories.Length == 0 && files.Length == 0 )
					sb.Append( "Folder is empty" );
				else
				if ( directories.Length > 0 )
				{
					sb.Append( directoryInfo.Name );
					sb.Append( Environment.NewLine );
					sb.Append( "Folders: " );
					sb.Append( Environment.NewLine );

					limiter = Math.Min( 5, directories.Length - 1 );
					for ( int i = 0; i <= limiter; i ++ )
					{
						sb.Append( directories[i].Name );
						if ( i < limiter )
							sb.Append( ", " );
					}

					if ( limiter < (directories.Length - 1) )
						sb.Append( "..." );
				}
				else
				if ( files.Length > 0 )
				{
					sb.Append( directoryInfo.Name );
					sb.Append( Environment.NewLine );
					sb.Append( "Files: " );
					sb.Append( Environment.NewLine );

					limiter = Math.Min( 5, files.Length - 1 );
					for ( int i = 0; i <= limiter; i ++ )
					{
						sb.Append( files[i].Name );
						if ( i < limiter )
							sb.Append( ", " );
					}

					if ( limiter < (files.Length - 1) )
						sb.Append( "..." );
				}


				e.ToolTipText = sb.ToString();
			}
		}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also