Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Summaries
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Collapse]Appearance and Conditional Formatting
    [Expand]Look and Feel
    [Collapse]Appearances
      Appearances Overview
      Tutorial: Custom Styles for Rows and Cells
      Tutorial: View and Column Appearance
      Customizing Appearances of Individual Columns, Card Fields and Bands
      Customizing Appearances of Individual Rows and Cells
      Style Schemes
    [Expand]Conditional Formats
    [Expand]Custom Painting
    [Expand]Alpha Blending and Background Images
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Tutorial: Custom Styles for Rows and Cells

This walkthrough is a transcript of the Custom Styles for Rows and Cells video available on the DevExpress YouTube Channel.

In this tutorial, you'll learn how to change data cell styles using events. You'll start with a grid displaying task data and having no conditional formatting applied. By handling the GridView.RowStyle event, you'll apply a different background color to rows whose Priority field value is High. Then, you'll use the GridView.RowCellStyle event to highlight Status cells within those rows, if the Status is set to New.

Expanded Starting Point

Start with an application that has a grid that displays task data and has no conditional formatting applied. Run the application to see how the data looks.

Expanded Customizing the Appearance of Individual Rows

Write the GridView.RowStyle event handler. The code changes the background color for rows whose Priority column value is High. The currently processed row is identified using the event's RowEventArgs.RowHandle parameter. The row's appearance settings are set using the RowStyleEventArgs.Appearance parameter.

Run the application and see the result. The "high priority" rows are now displayed with the specified gradient background. The gradient is applied to the entire row and not to individual cells.

Expanded Customizing the Appearance of Individual Cells

Return to design time and customize individual cells. For this purpose, handle the GridView.RowCellStyle event. It provides you with the CustomRowCellEventArgs.Column and CustomRowCellEventArgs.RowHandle parameters that identify the cell being processed. The handler will modify cells in the Status column if their value is New, provided that the record's Priority is set to High.

Run the application. You'll see that appearance settings imposed by the GridView.RowCellStyle event override those set in the GridView.RowStyle event.

Expanded See Also

How would you rate this topic?​​​​​​​