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
   [Collapse]Getting Started
    [Collapse]Walkthroughs
     [Collapse]Appearance and Conditional Formatting
       Tutorial: Conditional Formatting
       Tutorial: Custom Drawing
       Tutorial: Custom Styles for Rows and Cells
       Tutorial: View and Column Appearance
     [Expand]Data Editing
     [Expand]Hit Information
     [Expand]Data Binding and Working with Columns
     [Expand]Grid View - Columns, Rows and Cells
     [Expand]Banded Views
     [Expand]WinExplorer View
     [Expand]Tile View
     [Expand]Grouping
     [Expand]Filter and Search
     [Expand]Sorting
     [Expand]Summaries
     [Expand]Split Presentation
     [Expand]Row Preview Sections
     Data Grid and Views
   [Expand]Data Binding
   [Expand]Views
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Filter and Search
   [Expand]Summaries
   [Expand]Focus and Selection Handling
    Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
    Scrolling
   [Expand]Batch Modifications
   [Expand]Hit Information
    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]ASP.NET Core 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]CodeRush Classic
[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?​​​​​​​