[Expand]General Information
[Collapse]WinForms Controls
 [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
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Expand]Data Layout: Records, Rows and Cells
   [Expand]Data Editing and Validation
    Formatting Values
   [Expand]Drag and Drop
   [Collapse]Appearance and Custom Painting
      Style Schemes
      Customizing Appearances of Individual Rows
      Customizing Appearances of Individual Cells
      Specifying Styles Using Custom Painting Events
    [Expand]Custom Painting
    [Expand]Alpha Blending and Background Images
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst 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]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Customizing Appearances of Individual Cells

You can use the appearance mechanism to customize the appearance settings of data cells, cells located within a focused record and the focused cell. In addition you can customize the appearance of a particular editor row or multi-editor row to change the appearance of the cells residing within it. However these techniques don't allow you to provide custom appearance settings for individual cells. This topic will explain how to do this.

Expanded The Basics of Assigning Styles to Individual Cells

To change the appearance settings of individual cells, handle the VGridControlBase.RecordCellStyle event. This event fires for each cell before it's painted. The event's Row, RecordIndex and CellIndex parameters specify the cell currently being processed. The first parameter specifies the row in which the cell resides. If an editor row's cell is currently being processed, you will only need the RecordIndex parameter to identify the cell, since such rows display only a single cell within each record. If the cell's owning row is a multi-editor row, you will also need the CellIndex parameter to identify the cell. Please refer to the Cells Overview topic for details on how to identify cells.

To customize the appearance of cells use the style properties provided by the event's Appearance parameter.

The VGridControlBase.RecordCellStyle event gives you the ability to implement conditional cell formatting. This means that you can customize the styles of cells that satisfy specific conditions. Moreover, this method of customizing styles can be used to change the appearance settings of individual records. Assume that each record displays personal information and there is a Boolean row whose values specify if a particular person is an employee. In this case, you can display records with employees in a different style than other records. So there is no need to display a row containing Boolean values to distinguish between records. This lets you save screen space and makes your control more representative.

Expanded Customizing the Appearance of Records - A Sample

The sample in this section will handle the VGridControlBase.RecordCellStyle event to specify different appearance settings for the records whose Price field value is greater than $100,000.

The image below shows the result of such event handling.

Expanded Customizing the Appearance of Cells - A Sample

This section's sample will handle the VGridControlBase.RecordCellStyle event to customize the appearance of individual cells. It will paint the cells of a multi-editor row using different appearance settings. The image below shows the cells that are going to be painted.

The following image shows the result.

Is this topic helpful?​​​​​​​