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
130
Compressed Cardview : Changing caption colour
posted

We have up to 50 rows in a wingrid shown as a compressed cardview. I have been asked by a user if it would be possble to change the caption colour of each row depending on a status. This way they could see at a glance the status of an item, even when collapsed.

Is this possible ?

 

TIA

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi,

    There's no property to set the appearance of a card caption on an individual row. But this could be done using a DrawFilter.

    DrawFilters can be a bit intimidating if you haven't used them before, but this one is actually a pretty simple one.

     


    private void Form1_Load(object sender, System.EventArgs e)
            {
                this.ultraGrid1.DrawFilter = new CardCaptionDrawFilter();
            }

            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {

                // We must turn off themes on the card captions in order to be able to change their
                // colors. Otherwise, the themed colors will override the drawing.
                //
                ov.CardCaptionAppearance.ThemedElementAlpha = Alpha.Transparent;
            }

     


        public class CardCaptionDrawFilter : IUIElementDrawFilter
        {
            #region IUIElementDrawFilter Members

            bool IUIElementDrawFilter.DrawElement(DrawPhase drawPhase, ref UIElementDrawParams drawParams)
            {
                UltraGridRow row = drawParams.Element.GetContext(typeof(UltraGridRow)) as UltraGridRow;
                if (row != null)
                {
                    if ((int)row.Cells["Int32 1"].Value > 5)
                        drawParams.AppearanceData.BackColor = Color.Red;
                    else
                        drawParams.AppearanceData.BackColor = Color.Blue;               
                }

                return false;
            }

            DrawPhase IUIElementDrawFilter.GetPhasesToFilter(ref UIElementDrawParams drawParams)
            {
                if (drawParams.Element is CardCaptionUIElement)
                    return DrawPhase.BeforeDrawBackColor;

                return DrawPhase.None;
            }

            #endregion
        }

Children