This question is locked. New answers and comments are not allowed.
Hello,
I have a grid with AutogenerateColumns=true and all it's columns are generated dynamically. I want to set HeaderCellStyle property for it's columns. Please suggest a solution.
Thanks,
Abhay Gupta
I have a grid with AutogenerateColumns=true and all it's columns are generated dynamically. I want to set HeaderCellStyle property for it's columns. Please suggest a solution.
Thanks,
Abhay Gupta
5 Answers, 1 is accepted
0
Hello,
Maya
the Telerik team
You can define the style as an implicit one, thus applying it for all the columns. If you want to set it only to some particular ones, you can handle AutoGeneratingColumn event and assign the style defined in xaml to the HeaderCellStyle of the column.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
0
Abhay
Top achievements
Rank 1
answered on 13 Jan 2012, 06:44 AM
Implicit one???? I didnt get your point. Could you please suggest me a demo or something
0
Abhay
Top achievements
Rank 1
answered on 13 Jan 2012, 08:34 AM
reply please!!!!!
0
Pascal
Top achievements
Rank 1
answered on 01 Mar 2012, 11:32 AM
Can you please reply?
0
Accepted
Hello Pascal,
The other possible approach would be to set it explicitly during AutoGeneratingColumn:
All the best,
Maya
the Telerik team
You can define an implicit style that will be applied to all header cells:
<
UserControl.Resources
>
<
Style
TargetType
=
"telerik:GridViewHeaderCell"
>
<
Setter
Property
=
"Background"
Value
=
"SpringGreen"
/>
</
Style
>
</
UserControl.Resources
>
The other possible approach would be to set it explicitly during AutoGeneratingColumn:
//XAML:
<
UserControl.Resources
>
<
Style
x:Key
=
"MyHeaderCellStyle"
TargetType
=
"telerik:GridViewHeaderCell"
>
<
Setter
Property
=
"Background"
Value
=
"SpringGreen"
/>
</
Style
>
</
UserControl.Resources
>
//C#:
private void clubsGrid_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e)
{
e.Column.HeaderCellStyle = (Style)this.Resources["MyHeaderCellStyle"];
}
All the best,
Maya
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>