[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Expand]Controls and Libraries
 [Collapse]Common Features
  [Expand]Data Binding Common Concepts
  [Expand]Data Source Wizard
    File and Folder Browser Behaviors
    Persistence Behavior
    Indicator Behaviors
    Stub Glyph Behavior
    Banner Behavior
    Breadcrumb Behavior
    Disabled Cell Behavior
    Drag-and-Drop Behavior
    Magnifier Behavior
    Pager Navigation Behavior
    Scrollbar Annotation Behavior
    Snap Window Behavior
  [Expand]Application Appearance and Skin Colors
  [Expand]Filtering UI Context
   Find Panel Syntax
  [Expand]Graphics Performance and High DPI
  [Expand]Scaffolding Wizard
  [Expand]Formatting Values
   HTML-inspired Text Formatting
  [Expand]Save and Restore Layouts
   Clipboard - Copy and Paste Operations. Data Formatting
   Version Compatibility: Default Property Values
  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)

Disabled Cell Behavior

Expanded Overview

This Behavior allows you to disable cells in rows that meet a certain condition. Disabled cells are grayed-out according to the skin settings. Users cannot edit disabled cells. For example, you can disable rows that display orders that are older than six months.

Supported Controls

Expanded How to Attach the Behavior to a Control in the Designer

To attach the Behavior to a control, use the standard approach:

  • Drop the BehaviorManager component from Visual Studio's Toolbox onto the component tray.
  • Click Edit Behaviors in the component's smart tag menu.
  • In the Add drop-down menu, select Disabled Cell Behavior.

Expanded Options

When the Behavior is attached, use the editor to specify the following options:

  • The Appearance property — appearance settings applied to disabled cells. The default settings depend on the current skin. This property allows you to adjust them. For example, you can change the background color, font style, and so on.
  • The Expression property — a string value that specifies a condition that disabled rows should meet. For example, DateDiffMonth([Sales Date], Today()) > 6 disables rows with orders that are older than six months.

    Click the property's ellipsis button to invoke the expression editor.

  • The ProcessingCell event — allows you to enable/disable a cell.

    Use the FieldName and RecordId event arguments to identify the processed cell. The Disabled argument gets or sets whether the cell is disabled.

    The code below disables rows only if the user checked a dedicated option, but never disables cells in the 'Order ID' column.


    See Code Examples in the XtraGrid demo for more samples.

    You can add an event handler in the editor's events tab, or use the DisabledCellEvents component in the Properties window.

Expanded How to Attach the Behavior to a Control in Code

The example below shows how to attach the Behavior to a control in code, specify its settings, and add event handlers.

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