Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
250
Grid Row borders
posted

I searched for 'Borders' but did not find much help, so posting.

I need todisplay thick top-border or bottom-border only for some special rows in the Grid to display different blocks in the Grid. How to do this?

I found one knowledge base article about using 'DrawFilter'. Which I am using to see how it works. But that seems to apply globally to the Grid. How do I changes borders only for certain/specific rows or cells based on the content or row-index and column-key values?

Is there a way to get the current row-index and column-key in the DrawFilter?

thanks,

Piyush

  • 20872
    Offline posted

    Hello Piyush,

    Have you been able to use the Brain's suggestion in your scenario?

    If you have any further questions please do not hesitate to contact us.

     

  • 69832
    Offline posted

    The following code sample demonstrates some of the things you would have to do in a typical border-drawing implementation of the IUIElementDrawFilter interface. Note that this example does not draw the borders, but you can get the Graphics object from the drawParams.Graphics property and draw directly to it.

    public class RowBorderDrawFilter : IUIElementDrawFilter
    {

        bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
        {
            RowUIElement rowElement = drawParams.Element as RowUIElement;
            CellUIElement cellElement = rowElement == null ? drawParams.Element as CellUIElement : null;
            UltraGridRow row = null;
            Rectangle rect = Rectangle.Empty;

            if ( cellElement != null )
            {
                rect = cellElement.Rect;
                row = cellElement.Row;
                UltraGridColumn column = cellElement.Column;
            }
            else
            if ( rowElement != null )
            {
                rect = rowElement.Rect;
                row = rowElement.Row;
            }

            //  TODO: Return true if the border drawing was handled
            return false;
        }

        DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
        {
            if ( drawParams.Element is RowUIElement )
                return DrawPhase.BeforeDrawBorders;

            return DrawPhase.None;
        }
    }