[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Collapse]Rich Text Editor
   [Expand]Product Information
    Product Class Structure
    Supported Formats
   [Expand]Getting Started
   [Expand]RichEditControl Document
    Text Formatting
    Import and Export
   [Expand]Page Layout
    Spell Checking
    AutoCorrect Feature
    Track Changes
    Mail Merge
    Restrictions and Protection
   [Expand]Visual Elements
    Keyboard Shortcuts
    HTML Tag Support
      How to: Insert a Table
      How to: Create a Table with Fixed Column Width
      How to: Merge and Split Table Cells
      How to: Change Table Color
      How to: Create and Apply Table Style
      How to: Use Conditional Style
      How to: Delete a Table
    [Expand]Search and Replace
    [Expand]Spell Check
    [Expand]Import and Export
    [Expand]UI Customization
  [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)

How to: Use Conditional Style

The Rich Edit API allows you to set formatting rules to the specific table elements (first row, first cell, odd column, etc.). This feature is called conditional styles.

To create and apply a conditional style, perform the following steps.

  1. Create new table style using the TableStyleCollection.CreateNew method.
  2. Optionally, specify the newly created style's TableStyle.Parent property to derive it from an existing style.
  3. Create separate TableConditionalStyle objects for each desired table element type that needs to be formatted. To do so, call the TableConditionalStyleProperties.CreateConditionalStyle method repeatedly and pass different ConditionalTableStyleFormattingTypes enumeration values to this method as parameters.
  4. Specify additional settings for each TableConditionalStyle object you have:

  5. Add the style created in step 1 to the table styles collection by calling the TableCellStyleCollection.Add method. Note that styles not added to a corresponding collection cannot be applied to Rich Edit elements.
  6. To apply the style to a table, set this table's Table.Style property.
  7. Specify the table elements that should be formatted using the Table.TableLook property.

The following code creates a new table style which descends from the existing style, creates new conditional styles within that style using the TableConditionalStyleProperties.CreateConditionalStyle method and applies the style to a newly created table. Note that conditional styles are selectively applied using the Table.TableLook property.

The image below illustrates the result of code execution.

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