Hi,
when the mouse pointer hovers over a merged column, where the same content spans over several rows, the grid's built-in tooltip gets the same size as the merged area. This can be quite excessive! Is it possible to limit the size of the tooltip to 1 line, which is enough to show the column's content.
Thanks for your help!
Hi again,
After really checking the code (I write in VB.NET) I found out that I missed a "Not"...
It helped. Now I don't get the Exception.
Thanks for the help.
Regards
Mathias
I have a problem similar to the one that Manni wrote about, but I got an ArgumentException (see call stack below).
The exception occurs when I have ~3000 rows and one column is merged (all rows!). The tooltip I get, when the column width is less than the text inside the merged cell, is really high (more than the screen). I think that this is the reason why I get the exception.
I was trying the code that you were providing, Mike, but I never got the type MergedCellUIElement. But I think that this is the way forward, unless there is a fix for the problem already.
System.ArgumentException: Parameter is not valid. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawImage(Image image, Int32 x, Int32 y) at System.Drawing.Graphics.DrawImage(Image image, Point point) at Infragistics.Win.ToolTipForm.OnPaintBackground(PaintEventArgs e) at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, BooleandisposeEventArgs) at System.Windows.Forms.Control.WmPaint(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.Form.WndProc(Message& m) at Infragistics.Win.ToolTipFormEx.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Hi Manni,
The grid tooltips are the same size as the cell. I understand that something this can look a little odd in a merged cell case where the text is small. But the grid can't really make any intelligent judgements about when this looks good and when it doesn't.
You can alter this behavior using a CreationFilter.
Here's a sample CreationFilter that displays normal tooltips on Merged Cells. You just copy this code and set the grid's CreationFilter property to an instance of the MergedCellToolTipCreationFilter class.
#region MergedCellToolTipCreationFilter public class MergedCellToolTipCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { // Watched for MergedCellUIElements if (parent is MergedCellUIElement) { // See if it has a tooltip item and that it is not already a custom // MergeCellToolTipItem if (parent.ToolTipItem != null && (parent.ToolTipItem is MergeCellToolTipItem) == false) { // Replace the existing TooltipItem with a custom MergeCellToolTipItem parent.ToolTipItem = new MergeCellToolTipItem(parent.ToolTipItem); } } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // Do nothing, just return false. return false; } #endregion } #endregion //MergedCellToolTipCreationFilter #region MergeCellToolTipItem public class MergeCellToolTipItem : IToolTipItem { private IToolTipItem baseToolTipItem; public MergeCellToolTipItem(IToolTipItem baseToolTipItem) { this.baseToolTipItem = baseToolTipItem; } #region IToolTipItem Members public ToolTipInfo GetToolTipInfo(Point mousePosition, UIElement element, UIElement previousToolTipElement, ToolTipInfo toolTipInfoDefault) { // Create a new ToolTipInfo based on the values passed in. ToolTipInfo newToolTipInfo = baseToolTipItem.GetToolTipInfo(mousePosition, element, previousToolTipElement, toolTipInfoDefault); // Set the location to the location of the mouse. newToolTipInfo.Location = mousePosition; // Set the size to empty so the tooltip will automatically calculate the size based on the // contents. newToolTipInfo.Size = Size.Empty; // Exclude a rect where the mouse point is. Rectangle rect = new Rectangle(mousePosition, new Size(0,20)); newToolTipInfo.ExclusionRect = rect; // Return the new tooltip info. return newToolTipInfo; } #endregion } #endregion //MergeCellToolTipItem