Hello,
I'm trying to show the borders to the images in different colors (say green and red) in ultralistview depending on the status. I'm in a confusion whether to use DrawFilter or CreationFilter to implement it. I already have a code where I can see images in Ultralistview and now I'm trying to set up borders to those images but no luck.
Can anyone please help me with the sample code to implement it. Thank you in advance.
Thanks,
AB.
If you are going to draw anything or manipulate drawing you should use DrawFlter. Here is sample implementation of the drawFilter you need.
class DrawFilter:IUIElementDrawFilter { public bool DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams) { UltraListViewImageUIElement icon = drawParams.Element.GetDescendant(typeof(UltraListViewImageUIElement)) as UltraListViewImageUIElement; if (icon != null) { UltraListViewItem context = (UltraListViewItem)icon.GetContext(); switch(context.Text) { case "Item1": case "Item3": drawParams.AppearanceData.BorderColor = Color.Green; break; case "Item2": case "Item4": drawParams.AppearanceData.BorderColor = Color.Blue; break; } Rectangle rect = icon.Rect; rect.Inflate(0, 2); rect.Location = new Point(rect.X, icon.Rect.Y); drawParams.DrawBorders(UIElementBorderStyle.Solid, System.Windows.Forms.Border3DSide.All, rect); } return false ; }
public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams) { if(drawParams.Element is UltraListViewItemUIElement) { return DrawPhase.AfterDrawElement; } return DrawPhase.None; } }
Please let me know if you have any further questions.
It Worked Hristo. Thank you very much.