Hi, I have enabled Auto Preview for one of the columns in my grid, and it looks very nice, however, if I hover over it with the mouse I don't get a tooltip displaying the whole text as I would with the column! :( Is there any way to enable this behavior?
Thanks.
Hi,
The AutoPreview is the length of the whole row, so typically, it's long enough to show the whole text. So I don't think there's any tooltip functionality built-in to it.
You could implement your own tooltips using UltraTooltipManager or the inbox ToolTip class. Basically, you would change the tooltip on the grid in the MouseMove event based on the current location of the mouse. This technique is described in a number of places and there's a sample of it under the UltraToolTipManager samples that demonstrates how to set the grid tooltip based on the context.
Hi, the text column that I am previewing has multiple lines and can be quite long, and I only show the first 4 lines in the grid, so a tooltip would be very useful. I will look at the samples you've suggested. Thanks.
Hi Mike, I have looked at the WinToolTipManager sample as you suggested but I have a problem. The preview area does not appear to be a cell and the UIElement that's returned from ElementFromPoint is an UltraGridUIElement (which I think is the main grid element), and I can't see a way to get the corresponding preview rectangle and text from this element. :( Any pointers?
Thanks
Sorry, my mistake, it is actually a RowAutoPreviewUIElement that's returned, from which I can obtain the child TextUIElement, and the text. :) Thanks for your help.
Hi again, I can now display the tooltip OK, but the tip is always displayed when the mouse is over the preview area, even if all the text fits and is being displayed in the grid. Is there an easy way to determine if the text is being clipped, so that I only display the tip if there is text that can't be seen (just like a celltip). Thanks.
Hi Mike, that worked a treat, thanks!
Hi Brian,
Oops, sorry, I should have noticed that. I guess the tracking of the characters is off by default for efficiency.
What you have to do is trap for when the TextUIElement is created and added to the grid. You would do this using a CreationFilter. It's a pretty simple filter in this case:
public class TrackautoPreviewCharactersCreationFilter : IUIElementCreationFilter { #region IUIElementCreationFilter Members void IUIElementCreationFilter.AfterCreateChildElements(UIElement parent) { // Trap for the RowAutoPreviewUIElement. if (parent is RowAutoPreviewUIElement) { // Get it's child TextUIElement and set TrackCharactersRendered TextUIElement textUIElement = parent.GetDescendant(typeof(TextUIElement)) as TextUIElement; if (textUIElement != null) textUIElement.TrackCharactersRendered = true; } } bool IUIElementCreationFilter.BeforeCreateChildElements(UIElement parent) { // do nothing return false; } #endregion }
So you just set the grid's CreationFilter property to an instance of this class.
I see there is a property in the TextUIElement called IsTextFullyVisible, which looks like what I need, but it's documentation says it needs both TrackCharactersRendered and TrackTextArea to be true for it to work, and in my case TrackCharactersRendered is false. Any ideas how I can set this to true?
I have also been looking at possibly using the MeasureString method to work out the required size for the text, but I need a font for this and the only one I can find is the one from the grid control itself. This seems to work but I suspect it's not right since you can set an appearance for the preview row which can have font data, and therefore a different font. How can I find the font used for this through the TextUIElement?
The TextUIElement class has a property on it called IsTextFullyVisible that should fit your needs.