
Kristjan Einarsson
Top achievements
Rank 1
Kristjan Einarsson
asked on 11 Feb 2011, 10:10 AM
Hi,
I'm changing the cell colour in the RowLoaded event via:
And it works fine until I scroll the grid or just re-size the window, is this a bug or am I doing the completely wrong ?
cheers
kristján.
I'm changing the cell colour in the RowLoaded event via:
int
reservedCells = 5;
if
(item.Values[i].OriginalValueChanged)
{
e.Row.Cells[i + reservedCells].Background =
new
SolidColorBrush(Color.FromRgb(255, 0, 0));
}
And it works fine until I scroll the grid or just re-size the window, is this a bug or am I doing the completely wrong ?
cheers
kristján.
4 Answers, 1 is accepted
0
Hello,
Vlad
the Telerik team
RowLoaded is not the right place to style cells due to horizontal virtualization. Please use CellStyleSelector - you can check our demos for more info.
Kind regards,Vlad
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0

Kristjan Einarsson
Top achievements
Rank 1
answered on 11 Feb 2011, 10:38 AM
Hi, thanks I'll take a closer look to the demo but I'm doing all of the binding in codebehind, haven't found any good examples
cheers :)
cheers :)
0

Kristjan Einarsson
Top achievements
Rank 1
answered on 11 Feb 2011, 03:43 PM
do you have any examples where you do this in code behind that you can point to, I'm using dynamic columns for the grid and I have not found any.
Best regards
Kristján.
Best regards
Kristján.
0
Accepted
Hello Kristjan Einarsson,
You may set the CellStyleSelector for a column like follows:
Regards,
Maya
the Telerik team
Once you define the styles in the Resources section:
<
Window.Resources
>
<
my:NumberStyle
x:Key
=
"numberStyle"
>
<
my:NumberStyle.BigNumberStyle
>
<
Style
TargetType
=
"telerik:GridViewCell"
>
<
Setter
Property
=
"Background"
Value
=
"HotPink"
/>
<
Setter
Property
=
"Foreground"
Value
=
"White"
/>
</
Style
>
</
my:NumberStyle.BigNumberStyle
>
<
my:NumberStyle.SmallNumberStyle
>
<
Style
TargetType
=
"telerik:GridViewCell"
>
<
Setter
Property
=
"Background"
Value
=
"Yellow"
/>
<
Setter
Property
=
"Foreground"
Value
=
"Black"
/>
</
Style
>
</
my:NumberStyle.SmallNumberStyle
>
</
my:NumberStyle
>
</
Window.Resources
>
You may set the CellStyleSelector for a column like follows:
this.playersGrid.Columns[1].CellStyleSelector = (StyleSelector)this.Resources["numberStyle"];
Regards,
Maya
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>