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

How to apply CellStyle at RadGridView level?

2 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Debbie
Top achievements
Rank 1
Debbie asked on 10 Jun 2009, 02:30 PM
Hi there

We are using RadGridViews all over our application, and they all need to be styled according to our designs. Our grids are bound to a datasource; some of our grids are automatically generated (sutogeneratecolumns=true) and some have datacolumns defined (because they contain extra elements e.g. checkbox). We've created a CellStyle and would like to apply it "grid-wide" but how do we do this on grids that are autogenerated?

Thanks,
Debbie

2 Answers, 1 is accepted

Sort by
0
Kalin Milanov
Telerik team
answered on 11 Jun 2009, 07:24 AM
Hi Debbie,

To apply a CellStyle to an autogenerated first should attach an EventHandler to the DataLoaded event:
this.RadGridView1.DataLoaded += new EventHandler<EventArgs>(RadGridView1_DataLoaded); 

Then in the handler you go through the grid columns and apply the style:
void RadGridView1_DataLoaded(object sender, EventArgs e)  
{  
    foreach (var col in RadGridView1.Columns)  
    {  
        col.CellStyle = (Style)this.Resources["GridViewCellStyle"];  
    }  

I hope this helps.

Sincerely yours,
Kalin Milanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Keerti
Top achievements
Rank 1
answered on 06 Apr 2011, 10:13 PM
Hi,

In your above post you showed how to apply style for the columns.
My datatable contains datacolumns of typeof(object) , data can either be a bool , string , or List<string>.
So i need to have a checkbox , combobox or a textblock based on data.
Any help or suggesstions are greatly appreciated.

Thanks & Regards,
Keerti Somasundaram
Tags
GridView
Asked by
Debbie
Top achievements
Rank 1
Answers by
Kalin Milanov
Telerik team
Keerti
Top achievements
Rank 1
Share this question
or