Here is my situation. I have a number of columns in my application which have very long winded names. "Qty. Reserved From Order", "Qty. Reserved From Inventory", etc. This presents a bit of a problem when the user reduces the width these columns (which are side by side), so both of them read "Qty. Reser". If the user mouse overs the column it says the full column name in a little box that pops up. This is nice, but not quite handy enough for me.
What I'm planning on doing is writing code so that when the column is made too narrow, it will replace "Qty. Reserved From Order" with something like "Q-O". This is all fairly straight forward.
The problem is, when I do this, it all changes the mouse over thing for the column header. When I mouse over the column header, it displays "Q-O" (assuming the column is too narrow), where I want this functionality to still display "Qty. Reserved From Order".
So my question is, is there a way of having the column header text as one thing, but the column header mouse over thing displaying another thing?
I have tried playing with the ToolTipText property (column.Header.ToolTipText), which kind of works, but it displays a in a different area as where the normal header mouseover text appears.
Thanks.
I would think that the column's header overflow tooltip will get the name from the Caption of the header, so changing this so it's different in the grid itself will also affect the tooltip (as you're seeing in the application). I think the best approach here would be to use a DrawFilter and draw the text yourself:
private class DF : IUIElementDrawFilter{ #region IUIElementDrawFilter Members public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { TextUIElement textElem = (TextUIElement)drawParams.Element; HeaderUIElement headerElem = drawParams.Element.GetAncestor(typeof(HeaderUIElement)) as HeaderUIElement; if (headerElem != null) { // The TextSize property relies on the text having been rendered at least once, so if you need to // change the header caption when initially showing the grid, you need to measure the text yourself if (textElem.TextSize.Width > textElem.RectInsideBorders.Width) { string caption = headerElem.Header.Caption; string newCaption = "Blah"; // Change to whatever you need drawParams.DrawString(textElem.RectInsideBorders, newCaption, false, false); return true; } } return false; } public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if (drawParams.Element is TextUIElement) return DrawPhase.BeforeDrawForeground; return DrawPhase.None; } #endregion}
-Matt
Hi,
I need to display column header captions with superscript and subscript.
I have used graphics object and DrawString method to acheive the same but in a simple label control on Windows Form.
I need the same functionality in the Ultragrid column header.
Any suggestions ?
Thanks - that worked perfectly. Much better then the solution I was using before (using the AfterColPosChanged event).