Hi All,
How can i show a tooltip for ultralistview headers while in detailed view?
Thanks and Regards
Manikandan
The following code sample demonstrates how to show a tooltip for an UltraListViewColumnHeaderUIElement using the UltraToolTipManager:
private UltraToolTipManager toolTipManager = null;private UltraToolTipInfo toolTipInfo = null;
private void Form1_Load(object sender, EventArgs e){ this.listView.MainColumn.Text = "Name"; this.listView.View = UltraListViewStyle.Details;
int itemCount = 100; UltraListViewItem[ items = new UltraListViewItem[itemCount]; for ( int i = 0; i < itemCount; i ++ ) { items = new UltraListViewItem(); items.Value = string.Format("Item {0}", i); }
this.listView.Items.AddRange( items );
this.listView.MouseEnterElement += new UIElementEventHandler(this.listView_MouseEnterElement); this.listView.MouseLeaveElement += new UIElementEventHandler(this.listView_MouseLeaveElement);
}
private void listView_MouseEnterElement(object sender, UIElementEventArgs e){ UltraListView listView = sender as UltraListView;
// Create the UltraToolTipInfo if it is null if ( this.toolTipInfo == null ) { this.toolTipInfo = new UltraToolTipInfo(); this.toolTipInfo.ToolTipTitle = "UltraListView"; } // Create the UltraToolTipManager if it is null, and associate // it with the UltraListView and this form if ( this.toolTipManager == null ) { this.toolTipManager = new UltraToolTipManager(this.components); this.toolTipManager.ContainingControl = this; this.toolTipManager.SetUltraToolTip( listView, this.toolTipInfo ); }
// If the cursor is positioned over an UltraListViewColumnHeaderUIElement... UltraListViewColumnHeaderUIElement headerElement = e.Element as UltraListViewColumnHeaderUIElement; if ( headerElement != null ) { // Get the column; check for null because it will be if this is // the "dummy" column header, i.e., the one that is shown when // the actual columns don't fill the entire width of the control. UltraListViewColumnBase column = headerElement.Column; if ( column != null ) { // Set the ToolTipText and show the tooltip this.toolTipInfo.ToolTipText = column.TextResolved;
Rectangle toolTipRect = listView.RectangleToScreen(headerElement.Rect); Point toolTipLocation = new Point( toolTipRect.Right, toolTipRect.Top ); this.toolTipManager.ShowToolTip( this.listView, toolTipLocation ); } }}
private void listView_MouseLeaveElement(object sender, UIElementEventArgs e){ // Hide the tooltip when the cursor exits the bounds of an UltraListViewColumnHeaderUIElement if ( e.Element is UltraListViewColumnHeaderUIElement && this.toolTipManager != null ) this.toolTipManager.HideToolTip();}
I've made a thread about something related to this. How will you use the InitialDelay property in this code? ShowToolTip will not use the delay, it will just show the tooltip right away....