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
275
how to keep customised backcolor of selected rows?
posted

HI,

My grid show rows' backcolor based on one cell value by using ultraGrid1_InitializeRow.

I wanted those backcolors to be kept when rows selected, instead of default window highlight color.

To implemented that I tried DrawFilter. code is as below. Code runs fine. At run-time it shows row's backcolor (window highlight) is replaced by customised colotr but grid still show default highlight color.

Any idea ? thanks

        public class BackColorFilter : IUIElementDrawFilter
        {
            public DrawPhase GetPhasesToFilter(ref UIElementDrawParams drawParams)
            {
                if (drawParams.Element is RowCellAreaUIElement)
                {
                    return DrawPhase.BeforeDrawBackColor;
                }

                return DrawPhase.None;
            }

            public bool DrawElement(DrawPhase drawPhase,
              ref UIElementDrawParams drawParams)
            {
                switch (drawPhase)
                {
                    case DrawPhase.BeforeDrawBackColor:
                        RowCellAreaUIElement cell = drawParams.Element as RowCellAreaUIElement;

                        if (cell.Row.Selected && (bool)cell.Row.Cells["Excluded"].Value)
                        {
                            drawParams.AppearanceData.BackColor = cell.Row.Appearance.BackColor;
                        }
                        return true;
                }
                return false;
            }
        }