I am trying to create a 'yahoo search' like functionality in my app. For this I need to be able to have characters of the different colors in the same cell. I was able to do it in the standard DataGridView by creating my own DataGridViewColumn and DataGridViewCell, setting it as a column in the grid an overriding Paint function of the cell
trying o do the same using UltraCombo and its Grid, can't seem to find any function/event which does the painting
Also can't find a way to set my own UltraGridCell and UltraGridColumn in the UltraCombo dropdown grid.
Any ideas ?
thanks
EditorWithTextDisplayTextUIElement as an object type in GetPhasesToFilter.
1. No, I don't think this is right. You probably want to use the BeforeDrawForeGround phase, not after. After is too late, because the grid will have already drawn the text. You want the before so you can draw the text yourself and return true from DrawElement so that the grid does not draw the foreground. Also, I'm not sure it's the CellUIElement that draws the text. It's probably a child element of the cell that does it. The UIElementViewer Utility should help you to identify which element is the right one.
2. Returning true indicates that you handled the drawing and the grid should not draw. So in a case like this, you probably want to return true to let the grid know that the text drawing is done and it should not draw the text.
I decided to use the first approach now since the formatted string took too long to appear.
Having some problems with DrawFilter
I am trying to override the Drawing of the foreground by doing this :
class ColorDrawFilter : IUIElementDrawFilter
{
// If the element being drawn is a CellUIElement
return DrawPhase.AfterDrawForeground;
else
}
...
graphics.DrawString(.......)
return false;
And it is not working very well.
1. am i doing the right thing in GetPhasesToFilter() ? Which of the phases should I override ? I tried different things but could not stop the default drawing from happening
2. what should be the return value of the DrawElement ? I found different examples with false and true
Thanks for your reply , I have tried using the FormattedText style of the column and it is working fine, the only problem is it is very slow. My UltraCombo with 2000 rows in its dropdown takes more than 10 seconds to show up when I am in debug mode and about 2 seconds when I am in No Debug mode. Is there a way to make it work faster ? I assume now all the values in the drop down grid are treated as xml and it takes longer to display them
If you want to paint the cell text yourself, you need to use a DrawFilter. Check out the Infragistics Knowledge Base for lots of articles and samples of DrawFilters.
There is also an easier way. If you set the column's Style to FormattedText, you can use xml to display different colored text in the same cell without drawing it yourself. See the UltraFormattedLinkLabel or UltraFormattedTextEditor controls and check out the Value property to see the XML formatting that is supported.