This is a migrated thread and some comments may be shown as answers.

Alternating row style

2 Answers 117 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Domenico
Top achievements
Rank 1
Domenico asked on 27 Mar 2008, 05:05 PM
Hi, how can I change the style on alternate row? I see another post with same question, and you told to do it:

        private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)
        {
            if (e.RowElement.IsOdd)
            {
                if (!e.RowElement.IsCurrent)
                {
                    e.RowElement.BackColor = Color.Beige;
                }
                else
                {
                    e.RowElement.BackColor = Color.LightBlue;
                }
            }  
        }

but when you scroll, you loose the style.

2 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 28 Mar 2008, 02:23 PM
Hello Domenico,

I am sorry for the inconvenience.

When you scroll up and down, you also need to set the color for the Even rows. Please refer to the following code snippet:

private void radGridView1_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e)  
{  
    if (e.RowElement.IsOdd)  
    {  
        if (!e.RowElement.IsCurrent)  
        {  
            e.RowElement.BackColor = Color.Beige;  
        }  
        else 
        {  
            e.RowElement.BackColor = Color.LightBlue;  
        }  
    }  
    else 
    {  
        if (!e.RowElement.IsCurrent)  
        {  
            e.RowElement.BackColor = Color.White;  
        }  
        else 
        {  
            e.RowElement.BackColor = Color.LightBlue;  
        }  
    }     

If you have additional questions, do not hesitate to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Domenico
Top achievements
Rank 1
answered on 28 Mar 2008, 02:47 PM
Good. It works correctly now.

Thanks.
Tags
GridView
Asked by
Domenico
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Domenico
Top achievements
Rank 1
Share this question
or