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

Rowloaded event to change font style

1 Answer 58 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kavi
Top achievements
Rank 1
Kavi asked on 08 Aug 2010, 08:41 AM
Hi,
How do i set the text in a particular row of a gridview to bold and change the text color usign the RowLoaded event.

(e.Row

as GridViewRow)

 

1 Answer, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 10 Aug 2010, 07:59 AM
Hello Kavi,

If you want to perform conditional row formatting within gridView_RowLoaded use this code:

private void radGridView_RowLoaded(object sender, RowLoadedEventArgs e)
      {
          var row = e.Row as GridViewRow;
          var person = e.DataElement as Person;
          var style = new Style(typeof(GridViewRow));
          if (row == null || person == null) return;
          if (person.ID < 5)
          {
              style.Setters.Add(new Setter(GridViewRow.BackgroundProperty, new SolidColorBrush(Colors.Black)));
              style.Setters.Add(new Setter(GridViewRow.ForegroundProperty, new SolidColorBrush(Colors.Red)));
              style.Setters.Add(new Setter(GridViewRow.FontWeightProperty,FontWeights.Bold));
          }
          row.Style = style;
      }

Sincerely yours,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Kavi
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Share this question
or