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

when does RowFormatting fire

3 Answers 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ron Coffee
Top achievements
Rank 1
Ron Coffee asked on 15 Apr 2008, 02:30 PM
I am using the RowFormatting for alternating row color.  I am also planning to use it to insert a progress bar in a column.  It seems to me that the event does not fire until I click on the grid.  I would like this formatting to occur when the form loads.  Am I missing something?

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 16 Apr 2008, 08:37 AM
Hi Ron Coffee,

Thank you for the question.

RowFormating and CellFormating events fire eveyrtime a row or cell have been created. Keep in mind that this is the case only for visible ones. To handle the event, you should subscribe to it before creating the RadGridView's elements. In most cases that is before binding to DataSource

To add a progress bar in a column, it will be better if you use the CelFormating instead the RowFormating, because you have to modify cell by cell for one column, not an entire row.

I hope this was helps. If you have additional questions, do not hesitate to contact me again.

Greetings,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ron Coffee
Top achievements
Rank 1
answered on 23 Apr 2008, 10:52 PM
Thanks.  Now I have anothe related problem.  After I format the alternating rows, and the user scrolls down, all the rows trun the same color.  Any thoughts how to maintain the alternating colors?
0
Martin Vasilev
Telerik team
answered on 24 Apr 2008, 03:01 PM
Hello Ron Coffee,

Thank you for contacting us again.

When you use the RowFormating event for creating alternating rows you have to always set the colors for both the odd and even rows:
 
private void radGridView1_RowFormatting(object sender, RowFormattingEventArgs e)  
{  
    if (e.RowElement.IsOdd)  
    {  
        e.RowElement.BackColor = Color.SeaShell;  
 
    }  
    else 
    {  
        e.RowElement.BackColor = Color.White;  
    }  
 

Moreover, I want to bring your attention to our new version of RadGridView Q1 2008 version. It supports built in settings for alternating rows. Please review the code-block below:
 
this.radGridView1.EnableAlternatingRowColor = true;  
((GridTableElement)this.radGridView1.RootElement.Children[0]).AlternatingRowColor = Color.SeaShell; 

I hope this is useful for you. If you have other questions, do not hesitate to write me again. 

 
Regards,
Martin Vasilev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
GridView
Asked by
Ron Coffee
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Ron Coffee
Top achievements
Rank 1
Share this question
or